JSplitPane splitPane = new JSplitPane(); splitPane.setLeftComponent(btn1); // Left splitPane.setRightComponent(btn2); // Right
package com.java.myapp; import java.awt.EventQueue; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JSplitPane; 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, 432, 195); setTitle("ThaiCreate.Com Java GUI Tutorial"); getContentPane().setLayout(null); JButton btn1 = new JButton("Button 1"); JButton btn2 = new JButton("Button 2"); JSplitPane splitPane = new JSplitPane(); splitPane.setBounds(79, 31, 270, 25); splitPane.setLeftComponent(btn1); // Left splitPane.setRightComponent(btn2); // Right getContentPane().add(splitPane); } }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท