getContentPane().setLayout(new MigLayout("", "[][][][][][][]", "[][][][][][][]")); JButton btn1 = new JButton("Button 1"); getContentPane().add(btn1, "cell 3 1"); JButton btn2 = new JButton("Button 2"); getContentPane().add(btn2, "cell 5 2");
package com.java.myapp; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JButton; import net.miginfocom.swing.MigLayout; public class MyForm extends JFrame { /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { MyForm frame = new MyForm(); frame.setVisible(true); } }); } /** * Create the frame. */ public MyForm() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 458, 287); setTitle("ThaiCreate.Com GUI Tutorial"); getContentPane().setLayout(new MigLayout("", "[][][][][][][]", "[][][][][][][]")); JButton btn1 = new JButton("Button 1"); getContentPane().add(btn1, "cell 3 1"); JButton btn2 = new JButton("Button 2"); getContentPane().add(btn2, "cell 5 2"); JButton btn3 = new JButton("Button 3"); getContentPane().add(btn3, "cell 0 4"); JButton btn4 = new JButton("Button 4"); getContentPane().add(btn4, "cell 6 6"); } }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท