beginner need help adding buttons to frames
From: goodlie (wake_at_iprimus.ca)
Date: 03/24/05
- Next message: Tor Iver Wilhelmsen: "Re: detecting non-printable character "0x1F""
- Previous message: Dan: "Java class & Jsp page error"
- Next in thread: Roland: "Re: beginner need help adding buttons to frames"
- Reply: Roland: "Re: beginner need help adding buttons to frames"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 24 Mar 2005 02:13:57 -0500
Hi need to add a exit button to each of my frame but I dont want to add 4
buttons with four codes
to exit each frame.I want one exit button on each frame all buttons use the
same single exit and show it on frame. The last frame must have a exit
button so if I open the frame1 that contains an exit button it can close
frame1 frame2 frame3 from >>frame4
Also each frame should be label window 1,2,3,4 respectively
Each frame from 1 to 3 should have exit button to close individually.
Do not email me just post a message showing the code if you can help thank
you.
My code works well just need to know how to make the exit buttons .
import java.swing.JApplet;
import javax.swing.JInternalFrame;
import java.awt.Color;
import java.awt.Container;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
}
public class MyFrameAp extends JApplet{
private JInternalFrame frame1;
private JInternalFrame frame2;
private JInternalFrame frame3;
private JInternalFrame frame4;
private JButton buta_1;
private Container appletpane;
public void init(){
buta_1 =new JButton("buta_1");
frame1=new JInternalFrame("frame1");
frame2=new JInternalFrame("frame2");
frame3=new JInternalFrame("frame3");
frame4=new JInternalFrame("frame4");
FormListener formlistener=new FormListener();
buta_1.addActionListener(formlistener);
appletpane=getContentPane(); //Hungrain notation Content and Pane are
capital
appletpane.setLayout(null);
//Frame Color change
frame1.setBackground(Color.white);
frame2.setBackground(Color.yellow);
frame3.setBackground(Color.lightGray);
frame4.setBackground(Color.pink);
//Section Show frames
frame1.setVisible(false);
frame2.setVisible(false);
frame3.setVisible(false);
frame4.setVisible(false);
// Add the frames
appletpane.add(frame1);
appletpane.add(frame2);
appletpane.add(frame3);
appletpane.add(frame4);
// Section sets Bounds
frame1.setBounds(10,10,200,200);
frame2.setBounds(20,20,200,200);
frame3.setBounds(30,30,200,200);
frame4.setBounds(40,40,200,200);
// Button Section
appletpane.add(buta_1);
buta_1.setBounds(220,20,40,40);
}// closing init
public class FormListener implements ActionListener{
public void actionPerformed( ActionEvent evt){
if (evt.getSource()==buta_1){
MyFrameAp.this.buta_1press(evt);
frame1.setVisible(true);
}
}//close actionperform
}// close
//method buta_1 pressed
public void buta_1press(ActionEvent evt){
System.out.println("a1 pressed");
}
}// close MyFrameAp
- Next message: Tor Iver Wilhelmsen: "Re: detecting non-printable character "0x1F""
- Previous message: Dan: "Java class & Jsp page error"
- Next in thread: Roland: "Re: beginner need help adding buttons to frames"
- Reply: Roland: "Re: beginner need help adding buttons to frames"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]