package javaguidemomethod1;
import javax.swing.*;
public class Main {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setTitle("My First GUI Application - Method 1");
frame.setSize(400,500);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Creating a Container - Method 2
package javaguidemomethod2;
import javax.swing.*;
public class Main extends JFrame {
public Main() {
setTitle("My First GUI Application - Method 2");
setSize(400, 500);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
Main frame = new Main();
}
}
No comments:
Post a Comment