| | |
add and remove components...
Thread Solved |
•
•
Join Date: Jan 2009
Posts: 2
Reputation:
Solved Threads: 0
whats wrong with these code?
the buttons don't add or remove the panel..
someone help me!??plss..
the buttons don't add or remove the panel..
someone help me!??plss..
java Syntax (Toggle Plain Text)
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class addremove extends JPanel implements ActionListener{ private JButton addbut; private JButton revbut; private JPanel panel1; private JPanel panel2; public addremove() { addbut = new JButton ("Add"); revbut = new JButton ("Remove"); panel1 = new JPanel(); panel2 = new JPanel(); panel1.setBackground(Color.blue); panel2.setBackground(Color.red); setPreferredSize (new Dimension (218, 160)); setLayout (null); add (addbut); add (revbut); add (panel2); addbut.setBounds (20, 120, 80, 25); revbut.setBounds (120, 120, 80, 25); panel1.setBounds (20,10,180,60); panel2.setBounds (20,10,180,60); } public void actionPerformed(ActionEvent e) { if(e.getSource() == addbut) { remove(panel2); add(panel1); } else if (e.getSource() == revbut) { remove(panel1); add(panel2); } } public static void main (String[] args) { JFrame frame = new JFrame ("addremove"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); frame.getContentPane().add (new addremove()); frame.pack(); frame.setVisible (true); frame.setLocation(450,280); frame.setResizable(false); } }
![]() |
Similar Threads
- How do i remove XP Outlook Express (Windows NT / 2000 / XP)
- IIS isn't an option in add and remove components (Windows NT / 2000 / XP)
- Remove Hidden Windows Components (Windows tips 'n' tweaks)
- help rescue needed urgently (Windows NT / 2000 / XP)
- How do I get WMP to be my default player with Firefox? (Windows NT / 2000 / XP)
- Cant add/remove win components (Windows NT / 2000 / XP)
- Need help reinstalling Window components. (Windows NT / 2000 / XP)
- Problems re-installing IE (Web Browsers)
Other Threads in the Java Forum
- Previous Thread: Sending Images from server to client
- Next Thread: Parsing String
| Thread Tools | Search this Thread |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class client code compile compiler component database developmenthelp eclipse error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide image int integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loops mac main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying number online pearl problem program programming project qt recursion scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows working xor





