Results 1 to 2 of 2
  1. #1
    Daniel is offline Member
    Join Date
    Jun 2007
    Posts
    91
    Rep Power
    0

    Default I need create a JSplitPane

    Hi... How to create a JSplitPane using swing??

    Thanks in advance.

    Daniel:o

  2. #2
    Albert is offline Senior Member
    Join Date
    Jun 2007
    Posts
    114
    Rep Power
    0

    Default

    Well personally I always learn by example and so I found a pretty good example here:

    Java Code:
    import java.awt.*;
    import javax.swing.*;
    
    class SplitPane
    		extends 	JFrame
    {
    	private		JSplitPane	splitPaneV;
    	private		JSplitPane	splitPaneH;
    	private		JPanel		panel1;
    	private		JPanel		panel2;
    	private		JPanel		panel3;
    
    
    	public SplitPane()
    	{
    		setTitle( "Split Pane Application" );
    		setBackground( Color.gray );
    
    		JPanel topPanel = new JPanel();
    		topPanel.setLayout( new BorderLayout() );
    		getContentPane().add( topPanel );
    
    		// Create the panels
    		createPanel1();
    		createPanel2();
    		createPanel3();
    
    		// Create a splitter pane
    		splitPaneV = new JSplitPane( JSplitPane.VERTICAL_SPLIT );
    		topPanel.add( splitPaneV, BorderLayout.CENTER );
    
    		splitPaneH = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT );
    		splitPaneH.setLeftComponent( panel1 );
    		splitPaneH.setRightComponent( panel2 );
    
    		splitPaneV.setLeftComponent( splitPaneH );
    		splitPaneV.setRightComponent( panel3 );
    }
    
    	public void createPanel1()
    	{
    		panel1 = new JPanel();
    		panel1.setLayout( new BorderLayout() );
    
    		// Add some buttons
    		panel1.add( new JButton( "North" ), BorderLayout.NORTH );
    		panel1.add( new JButton( "South" ), BorderLayout.SOUTH );
    		panel1.add( new JButton( "East" ), BorderLayout.EAST );
    		panel1.add( new JButton( "West" ), BorderLayout.WEST );
    		panel1.add( new JButton( "Center" ), BorderLayout.CENTER );
    
    	}
    
    	public void createPanel2()
    	{
    		panel2 = new JPanel();
    		panel2.setLayout( new FlowLayout() );
    
    		panel2.add( new JButton( "Button 1" ) );
    		panel2.add( new JButton( "Button 2" ) );
    		panel2.add( new JButton( "Button 3" ) );
    	}
    
    	public void createPanel3()
    	{
    		panel3 = new JPanel();
    		panel3.setLayout( new BorderLayout() );
            panel3.setPreferredSize( new Dimension( 400, 100 ) );
            panel3.setMinimumSize( new Dimension( 100, 50 ) );
            
    		panel3.add( new JLabel( "Notes:" ), BorderLayout.NORTH );
    		panel3.add( new JTextArea(), BorderLayout.CENTER );
    	}
    
    	public static void main( String args[] )
    	{
    		// Create an instance of the test application
    		SplitPane mainFrame	= new SplitPane();
    		mainFrame.pack();
    		mainFrame.setVisible( true );
    	}
    }
    example

    Greetings
    Albert:rolleyes:

Similar Threads

  1. Vector create
    By Warren in forum New To Java
    Replies: 4
    Last Post: 03-02-2010, 03:42 AM
  2. JSplitPane nightmare
    By SwinGirl in forum SWT / JFace
    Replies: 1
    Last Post: 05-01-2008, 09:24 PM
  3. Create a new variable
    By mathias in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 07:48 AM
  4. how to create different arrays
    By osval in forum New To Java
    Replies: 2
    Last Post: 08-07-2007, 12:07 AM
  5. Create XML From XSD
    By Jack in forum XML
    Replies: 1
    Last Post: 07-09-2007, 01:56 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
  •