jframe

How do I change JPanel inside a JFrame on the fly?

To put it simple, there's a simple java swing app that consists of JFrame with some components in it. One of the components is a JPanel that is meant to be replaced by another JPanel on user action. So, what's the correct way of doing such a thing? I've tried panel = new CustomJPanelWithComponentsOnIt(); parentFrameJPanelBelongsTo.pack...

Java KeyListener for JFrame is being unresponsive?

Hey all, I am trying to implement a KeyListener into my JFrame. I have used the following code (at the moment im just trying to get this to work with my JFrame). System.out.println("test"); addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { System.out.println( "tester"); } ...

JButton expanding to take up entire frame/container

Hey everyone. I'm trying to make a swing GUI with a button and a label on it. im using a border layout and the label ( in the north field ) shows up fine, but the button takes up the rest of the frame (it's in the center field). any idea how to fix this? ...

closing my jframe without using the close(X) button and terminating the JVM

i have a frame that instantiates another frame but i don't want to use the close(x) button on the instantiated frame., so i created a button. how do i code that this button can be used to close the instantiated frame without quitting the JVM. ...

Java GUI Swing Model Explanation

I've been working with Java GUI for a while now but the whole model/structure of JFrames, paint(), super, etc is all murky in my mind. I need a clear explanation or link that will explain how the whole GUI system is organized. stackoverflow-ers: can you help me? Thanks everyone, some more answers would be better but this is great! ...

Java get JPanel Components

I have a JPanel full of JTextFields... for (int i=0; i<maxPoints; i++) { JTextField textField = new JTextField(); points.add(textField); } How do I later get the JTextFields in that JPanel? Like if I want their values with TextField.getText(); Thanks ...

Java GUI repainting problem?

This one's a tough one - I have a JFrame that generates JTextFields. When I go from generating 2 JTextFields to 12 JTextfields (for example), I see some error where there is an extra differently-sized JTextField at the end. It seems to be a repaint error. Main.java code: import java.awt.; import javax.swing.; public class Main ...

Where should I start drawing? (Java,GUI)

I have the points by the end of the GenerateButton class but now that I got my public double[][] matrix with all the points in, where do I begin drawing them??? my Main.java: import java.awt.*; import javax.swing.*; public class Main { public static Display display = new Display(); public static void main(String[] args) { ...

Automatically size JPanel inside JFrame

I have a JPanel subclass on which I add buutons, labels, tables, etc. To show on screen it I use JFrame: MainPanel mainPanel = new MainPanel(); //JPanel subclass JFrame mainFrame = new JFrame(); mainFrame.setTitle("main window title"); mainFrame.getContentPane().add(mainPanel); mainFrame.setLocation(100, 100); mainFrame.pack(); mainFra...

Detect which monitor shows the Window

I do have main application JFrame window which can include different components. I open a self implemented OnScreenKeyboard when the user select a editable textfield. The OSK is also a JFrame window. When the user drag the main window to another monitor, the OSK should also be shown on the same monitor. For this i have to detect the mon...

JPanel in JFrame in NetBeans

I have created a Java application (project) in NetBeans, in which I have designed a JFrame with menu bar, and different JPanels. I want these JPanels to appear inside the JFrame on action of different menu items, so that whenever the menu items are clicked different JPanels should appear inside the JFrame. I have designed both JFrame & J...

managing parent frame from child frame on java swing

I have a jframe (parent) which creates an input frame (child) where I get some parameter. In the "child" frame I have "ok" and "cancel" buttons. When "ok" button is pressed, the parent frame needs to be updated with new data. What is the best way to do that?? ...

how to focus a JFrame?

I am writing a small game, with one JFrame that holds the main game, and another JFrame that displays the score. the problem is, when I am done constructing them, the score JFrame always ends up focused! I have tried calling scoreDisplay.toFront(), scoreDisplay.requestFocus(), and even: display.setState(JFrame.ICONIZED); display.setStat...

using buttons in netbeans gui frame

Ok, so I'm pretty noob at JAVA, and programming in general really. I'm trying to make a rock, paper, scissors app that with run with a GUI interface. What I'm trying is the simplest thing I thought of, press a button for your choice (r, p, or s) and that will make a variable used in the rest of the program to compare to the computer's ...

JFrame title repaint

In my JFrame it loops to do some task, I want to see the status in the JFrame title, so I have something like this : frame.setTitle("Current status [ "+Auto_Count_Id+"/"+Auto_Count_Total+" ]"); But it's not repainting as I need it to. So I tried the following : <1> SwingUtilities.invokeLater(new Runnable() { public v...

Why wont my JFrame hide ?

I'm in the process of creating a GUI in Netbeans 6.1 for my senior design project but i've run into an annoying snag. Temporary Windows like my login PopUp and others wont disappear when i tell it. I've been researching how to solve this for about 2 months on an off. I've even mad a separate thread for my Pop Up but it still wont work...

how do you open web pages in java?

Is there a fairly simple way to open a web page within a GUI's JPanel? If not, how do you open a web page with the computer's default web browser? I am hoping for something that I can do with under 20 lines of code, and at most would need to create one class. No reason for 20 though, just hoping for little code... I am planning to o...

Java - How to create a custom dialog box?

I have a button on a JFrame that when clicked I want a dialog box to popup with multiple text areas for user input. I have been looking all around to try to figure out how to do this but I keep on getting more confused. Can anyone help? ...

Fixing flowlayout in Java

Hi I have created a GUI for my program in Java, and I have used flowlayout (didnt have much luck with borderlayout), but with flowlayout if the user resizes the program, everything goes out of alignment, so i'm wondering is there anyway to stop the frame of the program from being resized? if so how? Thank You ...

Java wait for JFrame to finish

I have a login frame that i have to wait for from another thread. Upon successful login frame disposes itself. And i want to pop up the main frame for the application. Right now i am watching a boolean value to determine when to fire up the main frame. What is the correct way of doing this? Watching a boolean value just does not feel ele...