Results 1 to 6 of 6
Thread: Panel sizing
- 10-11-2010, 01:50 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 5
- Rep Power
- 0
Panel sizing
I have the following code example. It contains a Frame, within the Frame is a TabbedPanel, and in the left tabbed panel is a SplitPane. The problem is the split panes are very small. I thought using the BorderLayout.CENTER when I added the split pane to the tabbed pane, would make the split pane use the full size. What needs to change in the code to get the split pane the full size?
Thanks for any help.
Java Code:import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; public class szTest extends JFrame { // Variables private JTabbedPane tabbedPane; private JPanel leftTabPane, rightTabPane; private JPanel leftSplitPane, rightSplitPane; private JSplitPane splitPane; // Constructor public szTest() { tabbedPane = new JTabbedPane(); // left tab pane leftTabPane = new JPanel(false); tabbedPane.addTab("Left Tab", leftTabPane); leftTabPane.setBorder(new LineBorder(Color.blue, 3)); // right tab pane rightTabPane = new JPanel(false); tabbedPane.addTab("Right Tab", rightTabPane); rightTabPane.setBorder(new LineBorder(Color.cyan, 3)); //Create a split pane leftSplitPane = new JPanel(false); rightSplitPane = new JPanel(false); leftSplitPane.setBorder(new LineBorder(Color.green, 2)); rightSplitPane.setBorder(new LineBorder(Color.red, 2)); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, leftSplitPane, rightSplitPane); splitPane.setDividerLocation(0.5); splitPane.setResizeWeight(0.5); // add split pane to left tab panel leftTabPane.add(splitPane, BorderLayout.CENTER); // add the tabbed panel to the frame add(tabbedPane, BorderLayout.CENTER); //add WindowListener for closing frame and ending program addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { System.exit(0); } } ); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } //End of Contructor public static void main(String args[]) { szTest sv = new szTest(); Container contentPane = sv.getContentPane(); sv.setTitle("Panel Size Test"); sv.setSize(600, 400); sv.setLocation(400, 250); sv.setVisible(true); sv.setResizable(true); } } //End of Swing szTest Class.
-
- 10-11-2010, 02:04 AM #3
Member
- Join Date
- Oct 2010
- Posts
- 5
- Rep Power
- 0
- 10-11-2010, 02:30 AM #4
Member
- Join Date
- Oct 2010
- Posts
- 5
- Rep Power
- 0
-
- 10-11-2010, 03:13 AM #6
Member
- Join Date
- Oct 2010
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Add panel to parent panel
By LovJava in forum AWT / SwingReplies: 10Last Post: 09-02-2010, 08:43 PM -
Dynamically changing JPanel in a JScrollPane - incorrect sizing
By david.stefka in forum AWT / SwingReplies: 3Last Post: 02-06-2010, 03:28 PM -
Adding a panel to a panel
By rclausing in forum New To JavaReplies: 7Last Post: 02-02-2010, 05:56 AM -
Trouble with Buffer Sizing
By Jeff in forum New To JavaReplies: 3Last Post: 02-07-2008, 01:43 PM -
Help needed with sizing components
By adlb1300 in forum New To JavaReplies: 2Last Post: 11-20-2007, 04:40 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks