JSplitPane UI

Hi Friends,
I want to view only top component of JSplitPane default other than showing top and bottom component of JSplitpane. Can any one tell me to solve this?
Thanks in advance
Regards,
Nandha.

Not sure if I understand the question. If you only want to see one component then why are you using a split pane?
If yoiu want the divider at the bottom by default then you can use the following code AFTER the GUI is visible:
splitPane.setDividerLocation(1.0);Or BEFORE the GUI is visible you can use high value like:
splitPane.setDividerLocation(1000);

Similar Messages

  • How to capture the event in driver JSplitPane

    Hi all, i have some problem with the JSplitPane.
    What i want to do is that:
    i need to capture the event throw when the user press the button in the driver of the JSplitPane, this is because i want to know wich side of the splitpane is complet visible.
    Thanks for your time!
    Luca

    I thought I would do up an example just for fun. As you drag the splitter bar the size of the two components and the splitter component is reported to the console along with the divider location. Interestinly, on my system (Windows XP, Java 1.41_02) when you move the bar downwards the divider location is consistantly two pixels past the height of the top component but when you drag the bar upwards the divider location and the height of the top component are the same.
    Does anyone have any ideas why that would be?
    Here is the test app:package splitPaneMonitor;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import javax.swing.JFrame;
    import javax.swing.JSplitPane;
    import javax.swing.JTextArea;
    public class SplitPaneFrame extends JFrame implements PropertyChangeListener  {
         public SplitPaneFrame()  {
              super ("Split pane test");
              //  Create the components to show in the split pane
              myTopComponent = new JTextArea ("This is the top component", 10, 40);
              myBottomComponent = new JTextArea ("This is the bottom component", 15, 40);
              //  Create the split pane
              mySplitter = new JSplitPane (JSplitPane.VERTICAL_SPLIT , true, myTopComponent, myBottomComponent);
              mySplitter.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, this);
              getContentPane ().setLayout(new BorderLayout ());
              getContentPane ().add (mySplitter, BorderLayout.CENTER);
         public void propertyChange (PropertyChangeEvent evt) {
              if (evt.getPropertyName () == JSplitPane.DIVIDER_LOCATION_PROPERTY)  {
                   System.out.println ("Split pane divider moved");
                   Dimension size = myTopComponent.getSize ();
                   System.out.println ("    The top component's size is: " + size.height +" h, "+ size.width + " w");
                   myBottomComponent.getSize (size);
                   System.out.println ("    The bottom component's size is: " + size.height +" h, "+ size.width + " w");
                   mySplitter.getSize (size);
                   System.out.println ("    The splitter's size is: " + size.height +" h, "+ size.width + " w");
                   System.out.println ("    The splitter divider location is: " + mySplitter.getDividerLocation ());
         private JTextArea myTopComponent;
         private JTextArea myBottomComponent;
         private JSplitPane mySplitter;
         public static void main(String[] args) {
              SplitPaneFrame appFrame = new SplitPaneFrame ();
              appFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              appFrame.pack();
              appFrame.setVisible (true);          
    }

  • Is it possible to add a button into the spliter area of a JSplitPane?

    I want to have a button in the spliter area of the JSplitPane. the purpose is to add an item from the upper component to the lower component. is it possible to do it in this way?

    the above link requires to register using $$$ before u can view the code, so poor me didn't go. but anyway, i worked out how to do this in the easiest way:
    JSplitPane mySplitPane = new JSplitPane();
    BasicSplitPaneDivider divider = ((BasicSplitPaneUI)mySplitPane.getUI()).getDivider();
    divider.setLayout(new FlowLayout());
    divider.add(new JButton("haha"));then u can try to show() this split pane in any frame or panel. just get the divider obeject then modify it in any manner u like.

  • Is it possible to add a JToolBar to JSplitPane?

    When I try to add Jtoolbar to JSplitPane, it gives me the following exception:
    Exception in Thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: cannot add to layout: unknown constraint: null
    Is it not possible to add a JToolBar to a JSplitPane? Is it because I have not defined what is supposed to happen when the user clicks "next" or "previous" yet? What I ultimately want to happen is for something to move up in all the components of the split pane (it's a nested pane) when I hit "next," and to move back when i hit "prev" (buttons in the jtoolbar)

    I believe that you don't want to add the JToolBar to the JSplitPane, but instead you want to add the JToolBar to the Panel that holds the JSplitPane. For eg:
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JSplitPane;
    import javax.swing.JToolBar;
    class FuSwing1
        private JPanel mainPanel = new JPanel();
        private JSplitPane splitpane;
        public FuSwing1()
            JToolBar toolbar = new JToolBar();
            toolbar.add(new JButton("foo 1"));
            JPanel redPanel = new JPanel();
            JPanel bluePanel = new JPanel();
            redPanel.setBackground(Color.red);
            bluePanel.setBackground(Color.blue);
            splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, redPanel, bluePanel);
            mainPanel.setPreferredSize(new Dimension(400, 400));
            mainPanel.setLayout(new BorderLayout());
            mainPanel.add(toolbar, BorderLayout.NORTH);
            mainPanel.add(splitpane, BorderLayout.CENTER);
        public JPanel getMainPanel()
            return mainPanel;
        public void setDividerLocation(double loc)
            splitpane.setDividerLocation(loc);
        private static void createAndShowUI()
            FuSwing1 fu1 = new FuSwing1();
            JFrame frame = new JFrame("FuSwing1");
            frame.getContentPane().add(fu1.getMainPanel());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            fu1.setDividerLocation(0.6);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        public static void main(String[] args)
            java.awt.EventQueue.invokeLater(new Runnable()
                public void run()
                    createAndShowUI();
    }

  • JTextArea as ListCellRenderer in JPanel with JSplitPane and text wrapping

    Hi.
    I have problem with JTextArea text wrapping. The JTextArea is used as ListCellRenderer in JList and it has set:
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);I can dynamically add new Notes, modify and remove notes on JList. The capacity of the Text is various so the size of cells is various.
    The JList is in JScrollPane configured like this:
    JList notesList = new JList();
    JScrollPane scrollPane = new JScrollPane(
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER
    scrollPane.setViewportView(notesList);This scrollPane is put on the left component in the JSplitPane.
    When I put one note with any capacity I want, word wrapping works great even if I move the splitter. The size of cells in JList changes as I want. When JList has more width the cells have less height, when JList has less width the cells height grows because of text wrapping.
    Problem
    Sometimes and I don't know when and why the cells size is fixed.
    I put new note to the list, JList lays the cell, calculate the size and disply it. It is good but when I move splitter the size of the cell is the same. It seems that during moving the splitter the JTextArea doesn't calculate their size.
    I would like in every cell in JList to see whole text wrapped. When I make more width by slider I would like to see whole text with less number of rows. When I make less width with the slider I want to see whole text wrapped and more higher cells.
    Can someone help me where to looking for ideas.

    Hi.
    I have problem with JTextArea text wrapping. The JTextArea is used as ListCellRenderer in JList and it has set:
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);I can dynamically add new Notes, modify and remove notes on JList. The capacity of the Text is various so the size of cells is various.
    The JList is in JScrollPane configured like this:
    JList notesList = new JList();
    JScrollPane scrollPane = new JScrollPane(
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER
    scrollPane.setViewportView(notesList);This scrollPane is put on the left component in the JSplitPane.
    When I put one note with any capacity I want, word wrapping works great even if I move the splitter. The size of cells in JList changes as I want. When JList has more width the cells have less height, when JList has less width the cells height grows because of text wrapping.
    Problem
    Sometimes and I don't know when and why the cells size is fixed.
    I put new note to the list, JList lays the cell, calculate the size and disply it. It is good but when I move splitter the size of the cell is the same. It seems that during moving the splitter the JTextArea doesn't calculate their size.
    I would like in every cell in JList to see whole text wrapped. When I make more width by slider I would like to see whole text with less number of rows. When I make less width with the slider I want to see whole text wrapped and more higher cells.
    Can someone help me where to looking for ideas.

  • JTable in JPanel in JTabbedPane in JScrollPane in JSplitPane problem

    I have a JSplitPane with a divider in the center; of which the top is a JPanel and the bottom is a JScrollPane that contains a JTabbedPane, for which each tab contains a JPanel which contains a JTable.
    When I move the divider up, so that it now takes up 75% of the JSplitPane, the JScrollPane and the JTabbedPane expand with the JSplitPane, but the JPanel that contains the JTable remains the same size that it had at the beginning.
    What I would like to see is more rows of the JTable as I move the divider to give the JScrollPane more room.
    Is there an easy way to keep all of the J components sizes in sync as the JSplitPane gets larger or smaller ? (JDK 1.3.1)

    Hi,
    The JPanels which you have inside each tab of the JTabbedPanes should have BorderLayout and the JScrollPanes which hold the JTables should be added with the BorderLayout.CENTER constraint. This will make sure that the JScrollPanes that contain the JTables occupy as much space as possible.
    Hope this helps,
    Ranga.

  • JSplitPane, JScrollPane and JTree resizing

    Hi,
    In a JSplitPane, I have, in the left part, a JScrollPane, containing a JTree and, in the right part, I have an other panel.
    When I click on different nodes in the JTree, the width of the left part changes, so the JSplitPane separator moves. How to avoid that ? I would prefer a scrolling move inside the JScrollPane !
    I am using JDK 1.3
    Thanks
    Olivier Scalbert

    Try to define the JScrollPane as
    public JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
    Use vsbPolicy and hsbPolicy like the VERTICAL_SCROLLBAR_AS_NEEDED
    HORIZONTAL_SCROLLBAR_AS_NEEDED respectively.
    Then define the setPreferredSize to your JScrollPane. This preferredSize must be smaller than the size of the Component view if you want to see the ScrollBar.
    By the way, when you define your JSplitPane have to define the setOneTouchExpandable(true);?

  • JSplitPane and Jtree

    Hi all,
    in my window I've got a JSplitPane with the left component that is a JScrollPane with a Jtree (used as a menu), while in the right side a customized JPanel that changes depending on the selection in the tree on the left.
    My panels are initially created as follows:
         this.splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
         this.splitter.setOneTouchExpandable(true);
    JScrollPane leftPanel = new JScrollPane( this.menuTree );
              leftPanel.setMinimumSize( new Dimension(300,300) );     
              leftPanel.setMaximumSize(leftPanel.getMinimumSize());
              // add the leftt and right panels
              this.splitter.setLeftComponent( leftPanel );
              this.imagePanel = new ImagePanel(ComponentBuilder.getLogoPath());
              this.rightPanel = this.imagePanel;
              this.splitter.setRightComponent(this.rightPanel);
              // add the splitter to myself
              this.add(new JScrollPane(this.splitter));where the imagepanel is a working panel that shows the project logo. Now what happens is that:
    1) the logo is cutted to a size I don't know how is calculated, since the image panel is working fine (if I place on a separate window I can see the image right)
    2) most important when a user selects something in the tree on the left panel, so the right panel changes, the left panel is moved around the window depending on the size of the right panel.
    Is it possible to fix the left panel not only as size, but also in the position of the window, thus the remaining part of the window will be occupied by the right panel without moving the left one? In my frame I'm using a BorderLayout, and the panel containing the splitpane is set at the center (no components on the right and on the left).
    Thanks,
    Luca

    Thanks for your reply, but the only thing I noticed is that the code you're showing works a little more with sizes, that is something I've already tried. By the way, the following is a running example that loads a tree/menu and the logo.png image.
    Any idea about its behaviour?
    Thanks,
    Luca
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    import java.util.*;
    import java.awt.image.*;
    class ImagePanel extends JPanel implements ImageObserver
         * The image to display
        protected Image image=null;
         * This flag indicates if the image is complete or not.
        protected boolean isComplete=false;
         * The dimension of the panel.
        protected int width=0,height=0;
         * This is the message to display during loading.
        protected String message="Loading...";
         * Default constructor.
         * @param image the image object.
        public ImagePanel(Image image)
              super();
              this.image=image;
         * Overloaded constructor. It try to load the image itself. You should use
         * this to avoid image flicking problems. This method use all the
         * capabilities of the ImageObserver.
         * @param image the image file name
        public ImagePanel(String image) {
              super();
              /* now load the image */
              Toolkit tk=Toolkit.getDefaultToolkit();
              this.image=tk.getImage(image);
              /* use the media tracker to wait untill the image is not loaded */
              try{
                  MediaTracker tracker=new MediaTracker(this);
                  tracker.addImage(this.image,0);
                  tracker.waitForID(0);
                  this.isComplete=true;
                  /* now that the image is fully loaded I need to resize the panel to
                  the size of the image */
                  this.width=this.image.getWidth(this);
                  this.height=this.image.getHeight(this);
                  this.setSize(width,height);
                  this.setMinimumSize(getSize());
                  this.setMaximumSize(getSize());
                  this.setVisible(true);
              catch(InterruptedException e){
                  this.message="Exception during loading process!";
                  this.isComplete=false;
         * Draw the image.
        public void paint(Graphics device)   {
              super.paint(device);
              if(this.isComplete==true)     {
                  device.drawImage(this.image,0,0,this.width,this.height,this);
              else     {
                  device.setColor(Color.RED);
                  device.drawString(this.message,20,20);
         * The update image method. This method is called for every update and or
         * error.
        public boolean imageUpdate(Image image,int infoFlags, int x, int y,
                        int width, int height)
              if((infoFlags & ALLBITS)==0)
                  /* the image is complete */
                  this.isComplete=true;
                  repaint();
                  this.setVisible(true);
                  return false;
              else
              if((infoFlags & ERROR)==0 || (infoFlags & ABORT)==0 )
                  /* error or abort */
                  this.isComplete=false;
                  this.message="Error during load process (or abort)";
                  this.repaint();
                  return true;
              else
              if((infoFlags & SOMEBITS)==0)
                  /* some other data loaded, show the loading process percent */
                  int originalWidth=this.image.getWidth(this);
                  int originalHeight=this.image.getHeight(this);
                  int currentWidth=image.getWidth(this);
                  int currentHeight=image.getHeight(this);
                  /* now calculate the total of pixels */
                  long originalTotal=originalWidth*originalHeight;
                  long currentTotal=currentWidth*currentHeight;
                  /* now calculate the percent */
                  float percent=(float)currentTotal/(float)originalTotal *100;
                  /* set the string */
                  this.message="Loading progress: "+(int)percent+" % done";
                  this.repaint();
                  return true;
              return true;
    public class MainPanel extends JPanel {
          * The split pane used for this panel.
         protected JSplitPane splitter = null;
          * The menu tree of this panel.
         protected JTree menuTree = null;
          * The parentFrame frame of this panel
         protected JFrame parentFrame = null;
          * The panel on the right of the window.
         protected JComponent rightPanel = null;
          * The menuTreeRoot node of the menu.
         protected DefaultMutableTreeNode menuTreeRoot = null;
          * The action menu of the JFrame that contains this panel. Such menu is changed depending on the panel
          * shown on the right panel.
         protected JMenu actionMenu = null;
          * The image panel with the image of the logo.
         protected ImagePanel imagePanel = null;
         public final String ROOT_STRING = "Gestione delle risorse umane";
         public final String LEVEL1A_STRING = "Parametrizzazione";
         public final String LEVEL2AA_STRING = "Competenze & Famiglie di competenze";
         public final String LEVEL2AB_STRING = "Gestione dei ruoli";
         public final String LEVEL2AC_STRING = "Associazione ruolo-competenza";
         public final String LEVEL1B_STRING   = "Varie";
         public final String LEVEL2BB_STRING = "Province";
         public final String LEVEL2BC_STRING = "Citta'";
         public final String LEVEL2BD_STRING = "Livelli di istruzione";
         public final String LEVEL2BE_STRING = "Livelli di competenza";
         public final String LEVEL3A_STRING   = "Personale";
         public final String LEVEL3AA_STRING = "Anagrafica di base";
         public final String LEVEL3AB_STRING  = "Ruoli, Competenze e Gradi di Istruzione";
         public final String LEVEL3AC_STRING  = "Storia delle valutazioni delle competenze";
         public final String LEVEL3AD_STRING  = "Valutazione";
          * Default constructor.
          * @param parentFrame the jframe that contains this panel
         public MainPanel(JFrame parent, JMenu actionMenu){
              super();
              this.parentFrame = parent;
              this.initGUI();
              this.actionMenu = actionMenu;
          * Shows the components on the main panel.
         public synchronized void initGUI(){
              // create the split pane
              this.splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
              this.splitter.setOneTouchExpandable(true);
              //this.splitter.setResizeWeight(0);                    // the right panel gets all the extra space
              // create the left panel with the tree
              DefaultMutableTreeNode root = new DefaultMutableTreeNode(ROOT_STRING);
                   DefaultMutableTreeNode level1a = new DefaultMutableTreeNode(LEVEL1A_STRING);
                        ContainerTreeNode level2aa = new ContainerTreeNode(LEVEL2AA_STRING);     // skills and families
                   DefaultMutableTreeNode level2ab = new DefaultMutableTreeNode(LEVEL2AB_STRING);
                        DefaultMutableTreeNode level2ac = new DefaultMutableTreeNode(LEVEL2AC_STRING);
                   DefaultMutableTreeNode level1b = new DefaultMutableTreeNode(LEVEL1B_STRING);
                        DefaultMutableTreeNode level2bb = new DefaultMutableTreeNode(LEVEL2BB_STRING);
                        DefaultMutableTreeNode level2bc = new DefaultMutableTreeNode(LEVEL2BC_STRING);
                        DefaultMutableTreeNode level2bd = new DefaultMutableTreeNode(LEVEL2BD_STRING);
                        DefaultMutableTreeNode level2be = new DefaultMutableTreeNode(LEVEL2BE_STRING);
                   DefaultMutableTreeNode level3a = new DefaultMutableTreeNode(LEVEL3A_STRING);
                        DefaultMutableTreeNode level3aa = new DefaultMutableTreeNode(LEVEL3AA_STRING);
                        DefaultMutableTreeNode level3ab = new DefaultMutableTreeNode(LEVEL3AB_STRING);
                        DefaultMutableTreeNode level3ac = new DefaultMutableTreeNode(LEVEL3AC_STRING);
                        DefaultMutableTreeNode level3ad = new DefaultMutableTreeNode(LEVEL3AD_STRING);
              // create the tree
              this.menuTreeRoot = root;
              level2ab.add(level2ac);
              level1a.add(level2aa);
              level1b.add(level2bc);
              level1b.add(level2bb);
              level1b.add(level2bd);
              level1b.add(level2be);
              level3a.add(level3aa);
              level3a.add(level3ab);
              level3a.add(level3ac);
              level3a.add(level3ad);
              root.add(level3a);
              root.add(level2ab);
              root.add(level1a);
              root.add(level1b);
              this.menuTree = new JTree(root);
              this.menuTree.setSize(200,200);
              JScrollPane leftPanel = new JScrollPane( this.menuTree );
              leftPanel.setMinimumSize( new Dimension(300,300) );     // it does not affects the dimension, but avoid to resize the left panel
              leftPanel.setMaximumSize(leftPanel.getMinimumSize());
              // add the leftt and right panels
              this.splitter.setLeftComponent( leftPanel );
              this.imagePanel = new ImagePanel("logo.png");
              this.rightPanel = this.imagePanel;
              this.rightPanel.setSize(400,400);
              this.splitter.setRightComponent(this.rightPanel);
              // add the splitter to myself
              this.add(new JScrollPane(this.splitter));
         public static void main(String argv[]){
             JFrame f = new JFrame();
             f.setSize(400,400);
             f.add(new MainPanel(f,null));
             f.setVisible(true);
    }

  • Problem with JSplitPane

    Hi!
    I have the following problem with JSplitPane: Whenever I add two components to the splitpane and then add the splitpane to a JPanel, the left component is minimized, i.e. not visible. I always have to manually readjust the splitter in order to see the left component. I also tried a bunch of combinations of setSize, etc. but nothing seems to help.
    Here's some code:
    public void setTables(Vector<DBTable> vec)
              _panel.setSize(650, 500);
              DefaultListModel m = new DefaultListModel();
              _tableList = new JList(m);
              // _tableList.setSize(new Dimension(300, 400));
              _infoArea = new JTextArea();
              _infoArea.setEditable(false);
              // _infoArea.setSize(new Dimension(250, 300));
              MetaDataListener listener = new MetaDataListener(_infoArea, _tableList);
              _tableList.addListSelectionListener(listener);
              for (DBTable table : vec)
                   m.addElement(table);
              JScrollPane scroll1 = new JScrollPane(_tableList);
              JScrollPane scroll2 = new JScrollPane(_infoArea);
              JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, scroll1, scroll2);
              split.setSize(new Dimension(600, 480));
              _panel.add(split, BorderLayout.CENTER);
              scroll1.setPreferredSize(new Dimension(300, 400));
              scroll1.setSize(new Dimension(300, 400));
              scroll2.setPreferredSize(new Dimension(300, 400));
              scroll2.setSize(new Dimension(300, 400));
              _panel.setVisible(true);
                                         //_frame referes to a JInternalFrame and _panel surprisingly to a JPanel
              _frame.getContentPane().add(_panel, BorderLayout.CENTER);
              _frame.setVisible(true);
              split.setDividerLocation(50.0);
         }Thanks!

    Nevermind I fixed it!

  • Problem of JSplitPane with ScrollPane

    Does JSplitPane work with ScrollPane?i am writing 2 ScrollPanes in a JSplitPane,but i can not move the bound.Thanks!

    It might be a little too late but I will put my 2 cents anyway...
    There is a scenario where mixing ScrollPane and JSplitPane is needed (unless you create your own AWTSplitPane): when you need to contain a heavyweight component (AWT) with a ScrollPane, you cannot use JScrollPane, that's for sure.
    The JSplitPane does not work because the minimumSize of the ScrollPane is set to its size and therefore JSplitPane won't reduce the component under its minimum size. The solution is to extend ScrollPane and override getMinimumSize method to whatever minimum size you decide.

  • JSplitPane problem with JTextArea

    The following piece of code has the problem in it. When you resize the splitpane you won't be able to decrease the size because of the setLineWrap(true).
    I am also wondering why the button in the bottom moves (and how do I stop it from moving) when the splitpane is made bigger.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    public class HMI extends JFrame {
         private JPanel map;
         private LeftMenu leftMenu;
         private JSplitPane split;
         public HMI(String title) {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                   SwingUtilities.updateComponentTreeUI(this);
              catch (Exception ex) {System.out.println("Look and feel does not exist");}
              map = new JPanel();
              leftMenu = new LeftMenu();
              split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftMenu,map);
              setLayout(new BorderLayout());
              add(split, BorderLayout.CENTER);
              split.setOneTouchExpandable(true);
              split.setBorder(BorderFactory.createEmptyBorder());
              setSize(1024,768);
              setLocationRelativeTo(null);
              setVisible(true);
              setDefaultCloseOperation(EXIT_ON_CLOSE);
    //NESTED
    public class LeftMenu extends JTabbedPane {
         TabLogg logg;
         public LeftMenu() {
              logg = new TabLogg();
              addTab("Logg",null,logg,"Visar loggar av information f�r kartan");
    //NESTED
    public class TabLogg extends JPanel {
         private JButton reset = new JButton("Clear logg");
         private TitledBorder border = BorderFactory.createTitledBorder("Logg");
         private JTextArea text = new JTextArea();
         public TabLogg() {
              setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
              text.setLineWrap(true);
              text.setEditable(false);
              reset.setAlignmentX(Component.RIGHT_ALIGNMENT);
              add(text);
              add(reset);
              text.setText("testststg sd sdgs gsdg sd gs gsdgsdg");
         public static void main (String[] arg) {
              HMI human = new HMI("V�ltnavigeringssystem Interface - Ny");
    }

    I want the button to stay alligned to the very left. Read the Swing tutorial on [How to Use Box Layout|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html] for an explanation and example of how the alignment of components works.
    Also, use the following to maximize the frame:
    //setSize(1024,768);
    setExtendedState(JFrame.MAXIMIZED_BOTH);

  • JSplitPane problem with Border layout

    I am using Swing utilities.
    I have a JFrame
    I am using Panel with BorderLayout(mainPanel)
    To this Panel i am adding a Button Panel which comprises of two JButtons.
    Now i am creating a BorderedLayout Panel (subPanel)and setting its size and adding it to the mainPanel to its West side.
    Now my requirement is having the Split Panel with JTree on left side Panel and Canvas on the right side Panel
    So i created a JScrollPane with Canvas attached to it with Always Scrollable option set for the right hand side Panel.
    For the left hand side Panel, i created the JPanel with JTree attached to it.
    I have passed these two components as parameters to the JSplitPane with Horizontal Split and added the splitPane to the subPanel.
    Now i got the Split Pane with JTree on the left side Panel and Canvas on the right side panel.
    Now my requirement is getting the Text Area and Progress /Status bar below the Split Pane.So first made a JTextArea with BorderLayout and added it to the subPanel to
    its South.To this TextArea i added a progress bar to show the status to its East.
    Everything till here were working fine.
    Problem is while i am moving the split pnae to its right side (towards Canvas ) the Canvas is getting shifted beyond the subPanel.
    How to solve this problem
    I will be thankful to you if anyone could give me the solution ASAP

    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • Big problem with JSplitPane

    Hello,
    I feel I'm going mad with Swing.
    I have a main main JTabbedPane: main.
    First component: JEditorPane : source
    Second Component: JPanel : view( = new JPanel())
    In view I have:
    JPanel toolbox to NORTH and JSplitPane: ds to CENTER.
    In ds I have:
    Left component: new JScrollPane(design) where design=new JPanel()
    Right component: JSplitPane(....) : called pe
    First problem:
    In ds the left component is too small. I tried to use all functions available , no result. I want the right component(pe) to have width=200, but no chance. It is too big. Why?
    Second problem:
    The scrolls are not appearing on the left at the ds(JSplitPane)
    Third problem:
    I add different components to design JPanel(the one which is placed into a JScrollPane which is related to the second problem) but nothing happens. They won't appear on design which is the same and without no scrolls.
    Please help me solve this Swing mistery.
    Thank you all.

    The split pane, by default, will size its two halves based on their preferred sizes. If the combined preferred sizes are too small (for the size of the spilt pane) then the extra space is distributed based on JSplitPane's resize weight. The default is to add the extra to the right hand side, see JSplitPane.setResizeWeight for an explanation. If you really want the right hand side to be exactly 200 pixels then you can programmatically move the divider to a location that would leave the right hand side to be 200. Or you can set the preferred size of the component you place there to 200 and set a resize weight that will give the extra space to the left instead of the right.
    I am not sure about why the scroll bars are not showing up. Does it need scroll bars?
    May I suggest creating a simple demo app to show the problem? Often I solve my own problems doing this otherwise you have some code for us to look at and play with.
    Ian

  • Problem with JSplitPane.setDividerPosition

    An applet has a split panel, a list of items shown to the left and a map display to the right.
    The problem I'm getting is that the divider bar insists on starting life in the middle.
    My intialisation looks like this:
        protected void initGui() {
            Container content = getContentPane();
            JMenuBar bar = new JMenuBar();
            setupMenu(bar, MK_MENU_DATASTORE, dataStoreMenu);
            setJMenuBar(bar);
            content.setBackground(new Color(0xfffeff));
            layerList = new JPanel();
            layerList.setLayout(new BoxLayout(layerList, BoxLayout.Y_AXIS));
            layerList.add(Box.createVerticalGlue());
            mapPanel = new ViewPanel();
            JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, layerList, mapPanel);
            split.setDividerLocation(ViewLayer.LAYERBOX_WIDTH);
            split.validate();
            content.add(split);
            validate();
        }Now the divider location I set seems to get squirreled away somewhere, because when I click the bar with the mouse it jumps to the correct position but it refused to initialise to the right position.

    Oops! Spotted it.

  • Problem while changing the JSplitpane in a dynamic way.

    Hi Everyone,
    In my application i'm changing the jsplitpane in a dynamic way.i'm posting the sample code thatz giving problem.Kindly compile and execute this.In the first frame i've done a split of two parts. The top component has got the name of the application and the bottom component has got some links related to that application. If the user click on this link ,i'm capturing the bottom component alone from the original splitpane and i'm breaking that into another split.
    upto this every thing works fine.Now the problem is when ever the user click on that link it'z capturing that event and doing consecutive split on the bottom frame.But i need that paricular split that user has already got to be repainted for all the time when user click on the link.Eventhough i've captured the main splitpane object in some other variable and assiging the same to the second window when user click on that url.But itz not recognizing that.
    Kindly some one help me to resolve this.
    import java.awt.Color;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.GridBagLayout;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    public class Test2 extends JPanel // implements KeyListener
        static Vector<String> arrAppName = new Vector<String>();
        public static JSplitPane splitPane,splitPane2;
        public void AppWin(final JFrame frame)
            Container contentPane = this;
            GridBagLayout gb = new GridBagLayout();
            contentPane.setLayout(gb);
            arrAppName.add("link");
            JLabel lab = new JLabel("<html><font color=#6698FF><a href>" + arrAppName.get(0) + "</a></font></html>");
            contentPane.add(lab);
            JScrollPane listScrollPane = new JScrollPane(contentPane);
            JLabel label = new JLabel("APPLICATION REPORT", JLabel.CENTER);
            Font font = label.getFont();
            Font font3 = font.deriveFont(25.0f);
            label.setFont(font3);
            label.setFont(label.getFont().deriveFont(Font.ITALIC));
            label.setHorizontalAlignment(JLabel.CENTER);
            label.setForeground(new Color(0x736AFF));
            JScrollPane labelScrollPane = new JScrollPane(label);
            labelScrollPane.setVisible(true);
            // Create a split pane with the two scroll panes in it.
            splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
            splitPane.setTopComponent(labelScrollPane);
            splitPane.setBottomComponent(listScrollPane);
            splitPane.setDividerLocation(100);
            Dimension minimumSize = new Dimension(100, 50);
            listScrollPane.setMinimumSize(minimumSize);
            labelScrollPane.setMinimumSize(minimumSize);
              splitPane2= new JSplitPane();
              splitPane2=splitPane;
            lab.addMouseListener(new MouseListener()
                public void mouseClicked(MouseEvent arg0)
                    displayMainFrame("link", frame);
                public void mousePressed(MouseEvent arg0)
                public void mouseReleased(MouseEvent arg0)
                public void mouseEntered(MouseEvent arg0)
                public void mouseExited(MouseEvent arg0)
        public void buildWindow(String link, JFrame frame)
            Container contentPane = this;
            GridBagLayout gb = new GridBagLayout();
            contentPane.setLayout(gb);
            JLabel label = new JLabel("Next Screen", JLabel.CENTER);
            Font font = label.getFont();
            Font font3 = font.deriveFont(25.0f);
            label.setFont(font3);
            label.setFont(label.getFont().deriveFont(Font.ITALIC));
            label.setHorizontalAlignment(JLabel.CENTER);
            label.setForeground(new Color(0x736AFF));
            JScrollPane buildWindowtop = new JScrollPane(label);
            buildWindowtop.setVisible(true);
            contentPane.add(buildWindowtop);
           /*assigning the main split pane object for all the consecutive call*/
            splitPane=splitPane2;
            JSplitPane splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
            splitPane1.setTopComponent(splitPane.getBottomComponent());
            splitPane1.setBottomComponent(contentPane);
            splitPane.setBottomComponent(splitPane1);
            splitPane.setOneTouchExpandable(true);
            splitPane.setDividerLocation(100);
            Dimension minimumSize = new Dimension(100, 50);
            buildWindowtop.setMinimumSize(minimumSize);
            splitPane1.setMinimumSize(minimumSize);
        } // end printing rows
        public static void displayFrame(String tname, JFrame framedisp, String buttonName, String tranCorrID,
            String buttonOption, JSplitPane buildSplit)
            Test2 mainDispPane = new Test2();
            framedisp.getContentPane().add(splitPane);
            framedisp.setVisible(true);
        public static void displayMainFrame(String link, JFrame framedisp)
            Test2 mainDispPane = new Test2();
            mainDispPane.buildWindow(link, framedisp);
            framedisp.getContentPane().add(splitPane);
            framedisp.setVisible(true);
        public static void main(String[] args)
            JFrame frame = new JFrame("MAIN WINDOW");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            Test2 mainPane = new Test2();
            mainPane.AppWin(frame);
            frame.getContentPane().add(splitPane);
            frame.setSize(1280, 1000);
            frame.setVisible(true);
        } // end main
    } // end Test2Thanks in Advance,
    Siva.

    anybody can help me this regard?

  • Error using JsplitPane in JInternalFrame...help...

    Hi,
    If I am adding JSplitPane to JInternalFrame, I am getting the following run time error:
    Any suggestions.. appreciated.
    Thanks....
    java.lang.NullPointerException: peer
    at sun.awt.windows.WCanvasPeer.create(Native Method)
    at sun.awt.windows.WComponentPeer.<init>(WComponentPeer.java:366)
    at sun.awt.windows.WCanvasPeer.<init>(WCanvasPeer.java:26)
    at sun.awt.windows.WToolkit.createCanvas(WToolkit.java:283)
    at java.awt.Canvas.addNotify(Canvas.java:76)
    at java.awt.Container.addNotify(Container.java:1579)
    at javax.swing.JComponent.addNotify(JComponent.java:4015)
    at java.awt.Container.addNotify(Container.java:1579)
    at javax.swing.JComponent.addNotify(JComponent.java:4015)
    at java.awt.Container.addNotify(Container.java:1579)
    at javax.swing.JComponent.addNotify(JComponent.java:4015)
    at java.awt.Container.addNotify(Container.java:1579)
    at javax.swing.JComponent.addNotify(JComponent.java:4015)
    at javax.swing.JRootPane.addNotify(JRootPane.java:483)
    at java.awt.Container.addNotify(Container.java:1579)
    at javax.swing.JComponent.addNotify(JComponent.java:4015)
    at java.awt.Container.addImpl(Container.java:374)
    at javax.swing.JLayeredPane.addImpl(JLayeredPane.java:201)
    at java.awt.Container.add(Container.java:284)
    at javax.swing.JLayeredPane.setLayer(JLayeredPane.java:343)
    at javax.swing.JLayeredPane.setPosition(JLayeredPane.java:424)
    at javax.swing.JLayeredPane.moveToFront(JLayeredPane.java:395)
    at javax.swing.JInternalFrame.moveToFront(JInternalFrame.java:1024)
    at javax.swing.JInternalFrame.toFront(JInternalFrame.java:1499)
    at javax.swing.JInternalFrame.show(JInternalFrame.java:1457)
    at java.awt.Component.show(Component.java:946)
    at java.awt.Component.setVisible(Component.java:903)
    at javax.swing.JComponent.setVisible(JComponent.java:1885)
    at Client.Init(Client.java:835)
    at Client.<init>(Client.java:659)
    at Client.main(Client.java:974)

    Hi, please post some code, if this do not help you.
    At line 835 in the class Client, Method init ( Client.Init(Client.java:835) ) the varibale peer is null.
    Have you forgotten to intialize peer before Init is called??
    Greetings
    Michael

Maybe you are looking for

  • Adobe CS5.5 Production Premium (32 bits)

    Hi, I need to create a deployment for the Adobe CS5.5 Production Premium32 bits version. It would be install on Windows XP Pro SP3. So I first created the "Premiere Pro CS4 and After Effects CS4, 32-bit support for CS5" package. It install without an

  • Web service invocation using pl/sql

    Hi Am trying to invoke a webservice using PL/SQL. Any ideas? I will be recieving the response as XML and then present the information using XSL which I have ready. Or any other ideas to invoke Siebel Analytics report from portal (no BPEL). I have WSD

  • Photo album launch button next to slider

    On my iPad there is a button to launch photo album / camera roll, next to the slider. On my iPhone this button opens the camera - which I would find more useful on the iPad. Is there a way to make the iPads button open the camera?

  • Full protected or purchased songs not playing

    full protected or purchased songs not playing all the way through.

  • RMI Policy Files

    grant {  permission java.net.SocketPermission "localhost:1099", "connect, resolve"; permission java.net.SocketPermission "localhost:1024-", "connect, resolve"; permission java.net.SocketPermission "localhost:1024-", "accept, resolve"; this is the bas