ҧҧ GUI Swing
:: ǡѺǹʴŢͧ :: ѡѺ Swing API ѹ
หน้า 1 จาก 1
ҧҧ GUI Swing
hello.java extends Frame
HelloPanel.java extends JPanel
package simple;
import java.awt.Frame;
import java.awt.Label;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class hello extends Frame{
public static int WIDTH =250;
public static int HEIGHT =150;
public hello(String lab){
super(lab);
}
public static void main(String[] args) {
hello frame = new hello("Hello Test");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e){
System.out.print("Exit Program");
System.exit(0);
}
});
frame.setSize(WIDTH,HEIGHT);
frame.add(new HelloPanel()); // Add File HelloPanel Contrainer
frame.show();
}
}
HelloPanel.java extends JPanel
package simple;
import java.awt.Font;
import java.awt.LayoutManager;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class HelloPanel extends JPanel{
public HelloPanel() {
JLabel textHello = new JLabel("Hello World");
textHello.setFont(new Font("Microsoft sans serif",Font.PLAIN,16));
add(textHello);
}
}
Re: ҧҧ GUI Swing
package simple;
import java.awt.Frame;
import java.awt.Label;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class hello extends Frame{
public static int WIDTH =550;
public static int HEIGHT =550;
public hello(String lab){
super(lab);
}
public static void main(String[] args) {
hello frame = new hello("Hello Test");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e){
System.out.println("Exit Program");
System.exit(0);
}
public void windowOpened(WindowEvent e){
System.out.println("ʴը");
}
public void windowDeactivated(WindowEvent e){
System.out.println("˹йա");
}
public void windowActivated(WindowEvent e){
System.out.println("");
}
});
frame.setSize(WIDTH,HEIGHT);
frame.add(new HelloPanel());
frame.show();
}
}
Similar topics
» ??èѴ LayOut ???Ѻ Swing
» ??????ҧ????? Enum
» ??????ҧ Start ??? Run ??ҧ?ѹ?ѧ???
» ??????ҧ Hello World
» ??????ҧ????? Generic (???????? array ??Ѻ)
» ??????ҧ????? Enum
» ??????ҧ Start ??? Run ??ҧ?ѹ?ѧ???
» ??????ҧ Hello World
» ??????ҧ????? Generic (???????? array ??Ѻ)
:: ǡѺǹʴŢͧ :: ѡѺ Swing API ѹ
หน้า 1 จาก 1
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ