// Panel Panel panel = new Panel(); // Label Label label = new Label(); panel.add(label); // Buton panel.setBackground(new java.awt.Color(255, 204, 204));
package com.java.myapp; import java.awt.Button; import java.awt.EventQueue; import java.awt.Frame; import java.awt.Label; import java.awt.Panel; import java.awt.event.WindowEvent; public class MyForm extends Frame { /** * @wbp.nonvisual location=202,119 */ private final Panel panel = new Panel(); public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { MyForm form = new MyForm(); form.setVisible(true); } }); } public MyForm() { // Create Form Frame super("ThaiCreate.Com Java GUI Tutorial"); setSize(434, 285); setLocation(500, 280); setLayout(null); // Panel Panel panel = new Panel(); panel.setBounds(110, 60, 190, 150); panel.add(new Button("Button 1")); // Label Label label = new Label(); label.setAlignment(java.awt.Label.CENTER); label.setText("ThaiCreate.Com"); panel.add(label); panel.add(new Button("Button 2")); panel.setBackground(new java.awt.Color(255, 204, 204)); panel.add(new Button("Button 3")); add(panel); // Close addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); } }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท