Hi,
I'm trying to develop a java program with a layout that resembles the following:
java.layout.jpg
However, I'm having trouble laying this out by hand (I typically use the NetBeans GUI designer, but I want to do it by hand this time). I've been coding it, but I can't decide which layout manager would be the best to use in this case. I really want to use the GridBagLayout manager, but I'm not sure if it would be best to use in this situation. Here is what I've come up with so far:
package application; public class AppMain { public static void main(String args[]) { new AppInterface(); } } package application; import java.awt.*; import javax.swing.*; public class AppInterface extends JFrame { private JPanel mainPanel; private JScrollPane tabScrollPane, textBoxScrollPane; private JTabbedPane tabPane; private JTextPane textBox; private GridBagConstraints constraints; public AppInterface() { initComponents(); setLocationRelativeTo(null); setVisible(true); } private void initComponents() { mainPanel = new JPanel(new GridBagLayout()); textBoxScrollPane = new JScrollPane(); textBox = new JTextPane(); constraints = new GridBagConstraints(); textBoxScrollPane.add(textBox); setTitle("Application Interface"); setSize(900, 800); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); mainPanel.setBackground(Color.yellow); constraints.gridx = 0; constraints.gridy = 0; constraints.fill = GridBagConstraints.BOTH; mainPanel.add(textBoxScrollPane, constraints); add(mainPanel); } }
I'm trying to get two different panels laid out with the GridBagLayout on each one so I can place the tab panel and text box on different panels. I need two panels side-by-side with the one on the left taking only about 25% of the JFrame and the right one taking 75% of the JFrame. Then, I hope to place the tab pane on the left panel and the text box on the right panel.
I know that JFrames have BoxLayouts as a default layout. How can I layout two panels with the BoxLayout on the JFrame with one taking 25% and the other taking 75% of the space? I think that would be a good place to start, then I can worry about placing the tab pane and text box. Thank you if you can offer any help.