我制作了一个 Java swing 应用程序。我的主班做所有的SwingUtilities.invokeLater(new Runnable()
事情。
我用过的第二堂课:
JPanel container = (JPanel) getContentPane();
然后通过调用添加所有位..
container.add([name of component]
我现在想将整个“应用程序”放入JSplitPane
. 因此,我希望我的应用程序在一侧,而其他东西在右侧。
我该怎么做呢?
public class one{
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame f = new App("main");
f.setSize(1920,1080);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
public class App extends JFrame {
SuppressWarnings("empty-statement")
public App(String title) {
super(title);
JPanel container = (JPanel) getContentPane();
container.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
JButton new button = new JButton("new");
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 2;
//ENTER LOTS OF CONSTRAINTS
container.add(new, c);
JButton next to button = new JButton("next to");
c.gridx = 1;
c.gridy = 1;
c.gridwidth = 2;
//ENTER LOTS OF CONSTRAINTS
container.add(new, c);
//I HAVE LOTS OF SWING COMPONENTS AND BUTTONS about 30
}
我希望所有这些都在拆分窗格的左侧?
我该怎么做呢?