Jframe Pop outs when clicking JButton
i'm working on a project but now i'm stuck, i'm trying to make i where if i press the options button another Jframe will pop out, i want this other Jframe to contain options/buttons/etc is there anyway to do this, and would like to only use JFrames for this project. can someone help me/get me in the right direction on how to make this, i have no idea how to add muti Jframes, I've tryed odds and ends and nothing worked.
Code :
private JButton sendButton;
Code :
sendButton = new JButton(" Send ");
add( sendButton );
sendButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
Main JFrame-
Code :
import javax.swing.JFrame;
public class MessageBoxCreator {
public static void main(String[] args){
MainClass creationFrame = new MainClass();
creationFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
creationFrame.setSize(625,415);
creationFrame.setVisible(true);
creationFrame.setResizable(false);
}
}
Re: Jframe Pop outs when clicking JButton
If you plan on going back to the window you navigate from, setVisible(boolean b) to false, and in the actionPerformed, set the new JFrame visible.
If you will don't plan on going back to the navigation frame, call dispose() and set the new JFrame to visible.
Re: Jframe Pop outs when clicking JButton
okay i understand that, but where do i make the the JFrame?
Re: Jframe Pop outs when clicking JButton
as of a new .java or what
Re: Jframe Pop outs when clicking JButton
If you want, you're only setting a JFrame object visible, so It can be a blank JFrame or your own subclass of it.
Really isn't any different to how you will have used JFrame's in the past
Re: Jframe Pop outs when clicking JButton
Thanks! :D
Code :
JFrame options = new JFrame("options");
options.setVisible(true);
options.setSize(200,200);
Re: Jframe Pop outs when clicking JButton
For future reference, always have setVisible as the last command issued when dealing with frames.
Re: Jframe Pop outs when clicking JButton
lol, thanks for the info but when adding things to the new jframe, do i just put it under the jframe or like call it? ex: options.sdsd = new label