Results 1 to 4 of 4
  1. #1
    Roobiks is offline Member
    Join Date
    Mar 2016
    Posts
    19
    Rep Power
    0

    Default How to split window and adjust size correctly

    Hello there!

    Java Code:
    import java.awt.BorderLayout;
    import java.awt.FlowLayout;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JSplitPane;
    
    public class mainclass {
    
    	private static JComponent createCenterPanel(){
    		
    		JSplitPane splitpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    
    		// This is where I want to split the window
    		// and adjust the size of the two separate frames
    
    		return splitpane;}
    
    
    	public static void main(String[] args) {
    
    		// Create and set up the window.
    		final JFrame frame = new JFrame("DashingPhoenix 1.1");
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    		// split the window.
    		// frame.add(createToolBarPanel(), BorderLayout.NORTH);
    		frame.add(createCenterPanel(), BorderLayout.CENTER);
    		// frame.add(createStatusBarPanel(), BorderLayout.SOUTH);
    		
    		// Display the window.
    		frame.setExtendedState(frame.MAXIMIZED_BOTH);
    		frame.pack();
    		frame.setVisible(true);
    
    		// set flow layout for the frame.
    		frame.getContentPane().setLayout(new FlowLayout());
    }}
    Please have a look at the comment in the CreateCenterPanel method.
    Can anyone help me please?

    Thank you,
    Roobiks
    Last edited by Roobiks; 04-18-2016 at 09:55 AM. Reason: not complete

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: How to split window and adjust size correctly

    Please provide an Short, Self Contained, Correct Example that demonstrates the problem. Keep the code as short as possible to demonstrate the problem.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Roobiks is offline Member
    Join Date
    Mar 2016
    Posts
    19
    Rep Power
    0

    Default Re: How to split window and adjust size correctly

    I have changed the content. Hopefully it is okay now.

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: How to split window and adjust size correctly

    I have never used this but as far as I can tell JSplitPane has a movable divider between two components that have been added to the splitpane object. Add two instances of JPanel() to splitpane and see what happens. Also, check out the tutorials in my signature. They have examples of this and many more.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Cannot adjust frame size from GUI in netbeans
    By poorav in forum NetBeans
    Replies: 0
    Last Post: 03-11-2012, 07:09 PM
  2. How to correctly use a fixed size thread pool?
    By johann_p in forum Threads and Synchronization
    Replies: 1
    Last Post: 09-19-2010, 02:04 AM
  3. Replies: 1
    Last Post: 07-19-2010, 12:31 AM
  4. Replies: 14
    Last Post: 09-18-2009, 04:48 AM
  5. How To:Use a JSlider to adjust Text size in a JPanel
    By louiebagz in forum AWT / Swing
    Replies: 2
    Last Post: 07-01-2007, 07:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •