Results 1 to 2 of 2
Thread: Gui
- 08-03-2011, 07:44 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 19
- Rep Power
- 0
Gui
i have placed JButton and JLabel.
i want that when i press the button i must be able to get a prompt to enter a string to the label and then the label should be displayed
this is what i did
import javax.swing.JFrame;
import javax.swing.*;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class EventHander extends JFrame{
JButton button1;
JLabel label1;
public EventHander(){
super("Image ");
setLayout (new FlowLayout());
button1 = new JButton ("Click");
label1 = new JLabel("");
add(button1);
add(label1);
event e = new event();
button1.addActionListener(e);
}
public class event implements ActionListener{
public void actionPerformed(ActionEvent e){
label1.setText(" i am mamoon rizwan");
}
}
public static void main (String args[]){
EventHander handle = new EventHander();
handle.setDefaultCloseOperation(JFrame.EXIT_ON_CLO SE);
handle.setVisible(true);
handle.setSize(500,500);
}
}
- 08-03-2011, 07:58 PM #2


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks