Java gui frame overlapping - java

I have an applet which has two buttons on it:
When we click Button1 a Frame is opened.
When we click Button2 a Dialog (which is a child the new frame) is presented.
Now suppose if when we click on Button1 then the new frame that is opened is now positioned behind my applet and not completely aligned with it (not minimized)
Now, when I press Button2 the Dialog that pops up is in front of my applet, but when I click on the header of the dialog, then both the applet and frame are brought forward (they both get displayed simultaneously).
So I basically want to have just the applet behind the dialog whenever it is clicked (leaving the Frame in the background)

Add a frame.setVisible(false); in Button2's ActionListener.

Related

I can't click or edit my button opened jframe

I have a jtable in second jframe (calisanEkrani) and I want those table informations printed to the third jframe (guvenliksorusturmaformu). I got the printing part and I made a button to open the third jframe but I can't focus (click or edit anything) and close the frame without closing the second.
How can I make the third jframe appear focused, editable (jtextfield) and when closed, comes back to the second frame?
This is the button action in calisanEkrani:
private void formcikartActionPerformed(java.awt.event.ActionEvent evt) {
guvenliksorusturmaformu gf = new guvenliksorusturmaformu();
guvenliksorusturmaformu.form_adsoyad.setText(this.ad_alani.getText());
guvenliksorusturmaformu.form_departman.setText(this.dept_alani.getText());
guvenliksorusturmaformu.form_maas.setText(this.maas_alani.getText());
gf.setVisible(true);
}
I want the guvenliksorusturmaformu frame on top and clickable. I can't even press 'X' to close it. It makes windows error sound and flashes but I can still play with the calisanEkrani (second jframe).
(Not very good at English so basic explanation or just the code will be good)

Frame within frame

I'm making a simple arithmetic game.
The first frame is a login screen, next this will close and then open a new frame after the user is logged in.
In the next frame, you can choose buttons which represent the game's modes and when I click a button a new frame opens.
What I am trying to accomplish is that I want is to continue working within this new frame. I don't want to keep moving between frames.
I am trying to make a back button for each mode so I can return to the original modes frame. I am only using the two frames for my program.
Is there a way I can choose the mode then go to a new screen and still be able to go back to the mode selection frame?
You could have 2 JPanels and when you press a button, an action listener does
Frame.remove(Panel1);
Frame.add(Panel2);

I need to make a JFrame or a JDialog that even if you change window it stays focused so that the keylistener will listen

I need to have a frame or dialog that stays focused even if I change window.
I am building an AutoClicker and it needs while it's clicking in another window to listen to my keyListener so that the user will be able to start/stop it.
d.setModalityType(ModalityType.APPLICATION_MODAL);// d is my JDialog
d.addKeyListener(this);
d.setAlwaysOnTop(true);
d.toFront();
d.requestFocus();
d.setFocusableWindowState(true);
d.setFocusable(true);

CheckBox change of state when X Button is pressed

I have got this problem:
I have JMenu, which consists of CheckBox. If that is checked (ItemEvent.selected), it opens a new JFrame, when unchecked (ItemEvent.Deselected) I dispose JFrame. Everything works OK. But when i push the "x" button on the top of the window, which is set as JFrame.DISPOSE_ON_CLOSE, I need to uncheck the checkbox in the JMenu.
Right now it's like this: You check, then program opens new window, which you close with "x" button, then you open menu again and checkbox is checked, but window is already close.
I tried to add some clickListener, but it!s getting destroyed with closing the frame.
Any advice will be welcomed :)
As the question hasn't been put very well, its hard to determine exactly what your issue is. However... If you want to automatically uncheck the box when the window has closed, you could use a window listener on your JFrame.
frame.addWindowListener( new WindowAdapter() {
#Override
public void windowClosing(WindowEvent we) {
//Uncheck the box
}
} );

Java Swing Maximize button of JFrame disappearss

I have created a java frame. It contains a JSplitPane. In the right partition of the splitpane , I have put JTextPane. Now I have kept JButton somewhere on the frame. When I click the button, a new JTextArea is inserted in the JTextPane as follows
JTextArea newTextBox = new JTextArea(1, 1);
StyleConstants.setComponent(style, newTextBox);
My problem is as soon as I insert JTextArea in JTextPane, the maximize button of my JFrame disappears. Can anyone tell me what could be the reason of happning this.
Maxmize button is unavailable on two conditions:
For a Dialog, in which case only close(X) button is availabe.
If frame.setResizable(false) has been called(i.e diabled resize of window)
So applying this to your case, my best guess is that somewhere in your button's action you may have made it unresizable.

Categories