Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- class NewFrame implements ActionListener {
- JFrame frame;
- JButton b;
- JDialog dialog;
- NewFrame(){
- frame = new JFrame();
- b = new JButton("Show Dialog");
- dialog = new JDialog(frame, "My Dialog", false);
- JLabel label = new JLabel("Hello, world!");
- b.addActionListener(this);
- dialog.add(label);
- frame.add(b);
- frame.setSize(400,400);
- frame.setVisible(true);
- }
- public void actionPerformed(ActionEvent event){
- dialog.setVisible(true);
- dialog.setSize(600,600);
- }
- }
- public class GUI {
- public static void main(String[] args) {
- new NewFrame();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement