with a simple example will output string " Hello World"
here's the code..
DemoFrame.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class DemoFrame {
private JLabel label;
public DemoFrame() {
label = new JLabel("Hallo Dunia...");
}
public void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Demo Frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(label, BorderLayout.CENTER);
//frame.pack();
frame.setBounds(0, 0, 300, 200); //ukuran frame
frame.setLocationRelativeTo(null); //frame di tengah layar
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
DemoFrame app = new DemoFrame();
app.createAndShowGUI();
}
});
}
}
import java.awt.event.*;
import javax.swing.*;
class DemoFrame {
private JLabel label;
public DemoFrame() {
label = new JLabel("Hallo Dunia...");
}
public void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Demo Frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(label, BorderLayout.CENTER);
//frame.pack();
frame.setBounds(0, 0, 300, 200); //ukuran frame
frame.setLocationRelativeTo(null); //frame di tengah layar
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
DemoFrame app = new DemoFrame();
app.createAndShowGUI();
}
});
}
}