Results 1 to 3 of 3
- 05-25-2011, 05:30 AM #1
Member
- Join Date
- May 2011
- Posts
- 32
- Rep Power
- 0
getting a set Visible(true) turned false with an actionhandler.
hello yall! working on a side project with a few friends and i'm getting the Main Menu working correctly. I can open a new JFrame but i cannot get the first menu to either close, or go invisible.
First page
EJava Code:package inter; import java.awt.*; import javax.swing.*; class Main { public static void main(String[]args){ boolean main =true; JFrame inter = new Inter(); inter.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); inter.setSize(300,300); inter.setLocation(500, 250); inter.setVisible(main); } }
2ND Page]Java Code:package inter; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Inter extends JFrame{ //was trying to get it to work :-P public boolean main = true; public JButton create,play,pc,mob,skills,items; public Inter(){ super("RPAGE"); setLayout(new FlowLayout()); play = new JButton("Play"); create = new JButton("Create"); add(play); add(create); main=true; cre crea =new cre(); create.addActionListener(crea); } private class cre implements ActionListener{ public void actionPerformed(ActionEvent create1){ JFrame imwithstupid = new JFrame("test"); imwithstupid.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); imwithstupid.setSize(300,300); imwithstupid.setVisible(true); mob=new JButton("Create a New Mob"); skills= new JButton("Create a New Skill"); items=new JButton("Create a New Item"); pc = new JButton("Create a New PlayerCharater!"); add(mob); add(skills); add(items); add(pc); //does nothing main=false; } } }
TY in advance ^__^
- 05-25-2011, 09:32 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
You may want to look into the dispose method. So the original frames button click will create and setup a new window, then dispose of the original frame.
- 05-25-2011, 02:33 PM #3
Similar Threads
-
while(true)
By ravian in forum New To JavaReplies: 7Last Post: 06-29-2011, 06:05 AM -
how to balance true and false instances per id ?
By aneuryzma in forum New To JavaReplies: 1Last Post: 03-27-2011, 02:35 PM -
Prime Number - true , false
By pinkdreammsss in forum Java AppletsReplies: 11Last Post: 05-04-2010, 02:49 PM -
true && !true
By SirFalcon in forum New To JavaReplies: 3Last Post: 10-29-2009, 02:33 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks