JSplitPane Divider problem...

I'm having problem with the JSplitPane divider. Ive learned that the MouseListener class is most likely the reason why the divider isn't performing as expected. I had to learn how to use the MouseListener interface and I've also learned that the divider is an instance of BasicSplitPaneDivider. I've finally got the divider to PARTIALLY work if I only set the following:
1) setting the setContinuousLayout(true)
//setting it to false wont work for some reason, I want to fix that, too. By setting it to false, the divider wont move :(.
and
2) if I move the mouse slowly, so the divider can follow the mouse. If I move my mouse too fast, then my divider will suddenly stop the moment the mouse cursor hovers away from the divider.
Can anyone help me fix the divider problem? Thanks in advance! Here's my code below:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.awt.event.MouseEvent;
import javax.swing.event.MouseInputAdapter;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
public class JSplitPaneDemo{
     public static void main(String args[]){
          //Practice p = new Practice("SplitPane Divider Works Now?");
          JSplitPaneDemo x = new JSplitPaneDemo();
          x.new Practice("SplitPane Divider Works Now?");
     public class DendrogramListener extends MouseInputAdapter
          Container contentPane;
          Component button1, button2, button3;
          JSplitPane splitter;
          Point mLocation;
          JFrame myFrame;
          MyGlassPane glass;
          private boolean inDrag = false;
          private boolean inButton = false;
          private boolean inDivider = false;
          public DendrogramListener(JFrame frame)
               this.myFrame = frame;
               this.contentPane = frame.getContentPane();
               this.mLocation = new Point();
          public DendrogramListener(AbstractButton aButton, AbstractButton b2, AbstractButton b3, MyGlassPane glass1, Container cP, JSplitPane split){
               this.button1 = aButton;
               this.button2 = b2;
               this.button3 = b3;
               this.glass = glass1;
               this.contentPane = cP;
               this.mLocation = new Point();
               this.splitter = split;
          public void mouseDragged(MouseEvent arg0) {
               // TODO Auto-generated method stub
               redispatchMouseEvent(arg0);
          public void mouseMoved(MouseEvent arg0) {
               // TODO Auto-generated method stub
               redispatchMouseEvent(arg0);
          public void mouseClicked(MouseEvent arg0) {
               // TODO Auto-generated method stub
               redispatchMouseEvent(arg0);
          public void mousePressed(MouseEvent arg0) {
               // TODO Auto-generated method stub
               redispatchMouseEvent(arg0);
          public void mouseReleased(MouseEvent arg0) {
               // TODO Auto-generated method stub
               redispatchMouseEvent(arg0);
               inDrag = false;
          public void mouseEntered(MouseEvent arg0) {
               // TODO Auto-generated method stub
               redispatchMouseEvent(arg0);
          public void mouseExited(MouseEvent arg0) {
               // TODO Auto-generated method stub
               redispatchMouseEvent(arg0);
          public void redispatchMouseEvent(MouseEvent e){
               inButton = false;
               inDrag = false;
               inDivider = false;
               Component component = null;
               JButton tempButton;
               Container container = contentPane;
               Point glassPanePoint = e.getPoint();
               mLocation = e.getPoint();
               Point containerPoint = SwingUtilities.convertPoint(glass, glassPanePoint, contentPane);
               int eventID = e.getID();
             component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y);
             if (component == null) {
                  //System.out.println("NULL");
                 return;
             if (component instanceof JButton) {
                 inButton = true;
             if(component instanceof BasicSplitPaneDivider){
                  inDivider = true;
                  testForDrag(eventID);
             if (inButton || inDivider)
                       Point componentPoint = SwingUtilities.convertPoint(glass, glassPanePoint, component);
                      component.dispatchEvent(new MouseEvent(component,
                                                           eventID,
                                                           e.getWhen(),
                                                           e.getModifiers(),
                                                           componentPoint.x,
                                                           componentPoint.y,
                                                           e.getClickCount(),
                                                           e.isPopupTrigger()));
               testForDrag(eventID);
         private void testForDrag(int eventID) {
             if (eventID == MouseEvent.MOUSE_PRESSED) {
                 inDrag = true;
     public class MyGlassPane extends JComponent {
          int x0, y0;
          Point mLocation;
          public MyGlassPane(AbstractButton aButton, AbstractButton b2, AbstractButton b3, Container cP, JSplitPane splitter){
               DendrogramListener dl = new DendrogramListener(aButton, b2, b3, this, cP, splitter);
               addMouseListener(dl);
               addMouseMotionListener(dl);
         public void setPoint(Point p) {
             mLocation = p;
     public class Practice extends JFrame implements ActionListener
          private MyGlassPane glassPane;
          public Practice(String str)
               super(str);
               setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
               setDefaultLookAndFeelDecorated(true);
               addComponents(this);
               pack();
               setVisible(true);
          public Practice addComponents(final Practice p)
               JPanel leftPane = new JPanel();
               JPanel midPane = new JPanel();
               JPanel rightPane = new JPanel();
               JLabel l1 = new JLabel("Left panel");
               JLabel r1 = new JLabel("Right panel");
               JLabel m1 = new JLabel("Middle panel");
               JButton b1 = new JButton("Button 1");
               JButton b2 = new JButton("Button 2");
               JButton b3 = new JButton("Button 3");
               leftPane.add(l1);
               leftPane.add(b3);
               b3.setActionCommand("b3");
               b3.addActionListener(this);
               leftPane.setPreferredSize(new Dimension(200, 300));
               midPane.add(m1);
               midPane.add(b1);
               midPane.setPreferredSize(new Dimension(200, 300));
               rightPane.add(r1);
               rightPane.add(b2);
               rightPane.setPreferredSize(new Dimension(200, 300));
               JSplitPane splitter2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rightPane, midPane);
               splitter2.setOneTouchExpandable(true);
               splitter2.setContinuousLayout(true);
               JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPane, splitter2);
               splitter.setOneTouchExpandable(true);
               splitter.setContinuousLayout(true);
               getContentPane().add(splitter);
               glassPane = new MyGlassPane(b1, b2, b3, p.getContentPane(), splitter);
               this.setGlassPane(glassPane);
               glassPane.setVisible(true);
               return p;
          public void actionPerformed(ActionEvent arg0) {
               // TODO Auto-generated method stub
               if("b3".equals(arg0.getActionCommand())){
                    JOptionPane.showMessageDialog(this, "Button 3 Pressed!");
}

The problem with your listener is that you are only dispatching events to the
button or divider when the mouse is directly over that component. This results
in the behavior you see with the divider: you have to move the mouse slowly
to keep it over the divider otherwise it gets over some other component and
you stop dispatching the events to it.
You actually have a similar problem with the buttons: if you click on one, it
gets the event but if you then drag the mouse out of the button and release
the mouse, it still triggers the button! This is not how buttons work: if you
release the mouse when it is not over the button, it shouldn't trigger.
Try this for your listener:
     public class DendrogramListener extends MouseInputAdapter {
          Component redispatch;
          boolean inside;
          Container contentPane;
          Component button1, button2, button3;
          JSplitPane splitter;
          Point mLocation;
          JFrame myFrame;
          MyGlassPane glass;
          private boolean inDrag = false;
          private boolean inButton = false;
          public DendrogramListener( JFrame frame ) {
               this.myFrame = frame;
               this.contentPane = frame.getContentPane();
               this.mLocation = new Point();
          public DendrogramListener( AbstractButton aButton, AbstractButton b2,
                    AbstractButton b3, MyGlassPane glass1, Container cP,
                    JSplitPane split ) {
               this.button1 = aButton;
               this.button2 = b2;
               this.button3 = b3;
               this.glass = glass1;
               this.contentPane = cP;
               this.mLocation = new Point();
               this.splitter = split;
          public void mouseDragged( MouseEvent arg0 ) {
               redispatchMouseEvent( arg0 );
          public void mouseMoved( MouseEvent arg0 ) {
               redispatchMouseEvent( arg0 );
          public void mouseClicked( MouseEvent arg0 ) {
               redispatchMouseEvent( arg0 );
          public void mousePressed( MouseEvent arg0 ) {
               redispatchMouseEvent( arg0 );
          public void mouseReleased( MouseEvent arg0 ) {
               redispatchMouseEvent( arg0 );
               inDrag = false;
               inButton = false;
          public void mouseEntered( MouseEvent arg0 ) {
               redispatchMouseEvent( arg0 );
          public void mouseExited( MouseEvent arg0 ) {
               redispatchMouseEvent( arg0 );
          public void redispatchMouseEvent( MouseEvent e ) {
               int eventID = e.getID();
               Point glassPanePoint = e.getPoint();
               Point containerPoint = SwingUtilities.convertPoint( glass, glassPanePoint, contentPane );
               if ( !inDrag && !inButton && eventID == MouseEvent.MOUSE_PRESSED ) {
                    redispatch = SwingUtilities.getDeepestComponentAt( contentPane, containerPoint.x, containerPoint.y );
                    inButton = ( redispatch instanceof JButton );
                    inside = inButton;
                    if ( !inButton )
                         inDrag = ( redispatch instanceof BasicSplitPaneDivider );
               if ( inButton || inDrag ) {
                    if ( inButton )
                         eventID = possiblySwitchEventID( eventID, containerPoint );
                    Point componentPoint = SwingUtilities.convertPoint( glass, glassPanePoint, redispatch );
                    redispatch.dispatchEvent( new MouseEvent( redispatch, eventID, e.getWhen(), e.getModifiers(),
                              componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger() ) );
          private int possiblySwitchEventID( int eventID, Point containerPoint ) {
               int switchedID = eventID;
               Component deepest = SwingUtilities.getDeepestComponentAt( contentPane, containerPoint.x, containerPoint.y );
               if ( deepest == redispatch ) {
                    if ( ! inside )
                         switchedID = MouseEvent.MOUSE_ENTERED;
                    inside = true;
               } else {
                    if ( inside )
                         switchedID = MouseEvent.MOUSE_EXITED;
                    inside = false;
               return switchedID;
     }: jay

Similar Messages

  • Another JSplitPane divider cursor problem

    I have the same problem discussed elsewhere in that the cursor doesn't change to a E_RESIZE_CURSOR when it's over a split panel divider. The code is in a large application too huge to post, and my attempts to simplify it have been unable to reproduce the problem. I have implemented the solution suggested in [http://forums.sun.com/thread.jspa?forumID=57&threadID=642994] but, although the mouse listener methods are indeed called, the cursor doesn't change. I have also tried calling setCursor on the parent of the JSplitPane, and on the JRootPane, but it doesn't change. In each case the mouse listener is called but the setCursor call has no effect.
    All the discussions on setCursor having no effect I've found are specific to JDialog. In my case, I have a deep window stack starting with JFrame, JRootPane, JLayeredPane, down through several JPanels, a JSplitPane, more JPanels, my JSplitPane, which contains 2 JPanels, and so on.
    What would prevent the JSplitPane divider from changing the cursor itself? Assuming it's trying, just as my explicit mouse listener is, what could be overriding, obscuring, or intercepting my cursor change?
    Any help would be most welcome
    Thanks!

    I have the same problem discussed elsewhere in that the cursor doesn't change to a E_RESIZE_CURSOR when it's over a split panel divider. The code is in a large application too huge to post, and my attempts to simplify it have been unable to reproduce the problem. I have implemented the solution suggested in [http://forums.sun.com/thread.jspa?forumID=57&threadID=642994] but, although the mouse listener methods are indeed called, the cursor doesn't change. I have also tried calling setCursor on the parent of the JSplitPane, and on the JRootPane, but it doesn't change. In each case the mouse listener is called but the setCursor call has no effect.
    All the discussions on setCursor having no effect I've found are specific to JDialog. In my case, I have a deep window stack starting with JFrame, JRootPane, JLayeredPane, down through several JPanels, a JSplitPane, more JPanels, my JSplitPane, which contains 2 JPanels, and so on.
    What would prevent the JSplitPane divider from changing the cursor itself? Assuming it's trying, just as my explicit mouse listener is, what could be overriding, obscuring, or intercepting my cursor change?
    Any help would be most welcome
    Thanks!

  • JSplitPane divider (One touch expandable)

    Hi all,
    I am having some problems with the JSplitPane divider. I am using onetouch expandable.
    I want to stop the divider moving all the way up to the top of the window when the up arrow is clicked on. When you drag the divider up it stops near the top but doesn't go all the way up. but click on the up arrow on the divider bar and it rises completely to the top. How can I stop this from happening.
    I have managed to add an action listener to the buttons on the divider bar, In the action listener I do the following - splitPane.setDividerLocation(0.1);
    splitPane.updateUI();
    This works but then an exception is thrown -
    Exception occurred during event dispatching:
    java.lang.NullPointerException
         at javax.swing.plaf.basic.BasicSplitPaneDivider$OneTouchActionHandler.actionPerformed(BasicSplitPaneDivider.java:916)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1504)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:378)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:216)
         at java.awt.Component.processMouseEvent(Component.java:3717)
         at java.awt.Component.processEvent(Component.java:3546)
         at java.awt.Container.processEvent(Container.java:1167)
         at java.awt.Component.dispatchEventImpl(Component.java:2595)
         at java.awt.Container.dispatchEventImpl(Container.java:1216)
         at java.awt.Component.dispatchEvent(Component.java:2499)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2458)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2223)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2132)
         at java.awt.Container.dispatchEventImpl(Container.java:1203)
         at java.awt.Window.dispatchEventImpl(Window.java:918)
         at java.awt.Component.dispatchEvent(Component.java:2499)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:336)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:134)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:101)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:96)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:88)
    Can anyone help me out?
    thanks,
    Paul.

    I have partial solution to the above problem but in doing so have encountered another problem that I can see no solution to. Can anyone help?
    I have a calss that extends BasicSplitPaneDivider and in this calss i overide the OneTouchActionHandler with a version that sets the top value to be the top of the frame + the height of the component I want left shown. My problem is that this code never runs. The origional OneTouchActionHandler in the BasicSplitPaneDivider runs not my version. How can I get my version to run.
    The version in BasicSplitPaneDivider is protected.
    This code never runs.
    <pre>
    * Listeners installed on the one touch expandable buttons.
    public class OneTouchActionHandlernew implements ActionListener {
         /** True indicates the resize should go the minimum (top or left)
         * vs false which indicates the resize should go to the maximum.
         private boolean toMinimum;
         OneTouchActionHandlernew(boolean toMinimum) {
         this.toMinimum = toMinimum;
    public void actionPerformed(ActionEvent e) {
    Insets insets = splitPane.getInsets();
         int lastLoc = splitPane.getLastDividerLocation();
    int currentLoc = splitPaneUI.getDividerLocation(splitPane);
         int newLoc;
         // We use the location from the UI directly, as the location the
         // JSplitPane itself maintains is not necessarly correct.
    System.out.println("The action listener is being used ");
         if (toMinimum) {
              if (orientation == JSplitPane.VERTICAL_SPLIT) {
              if (currentLoc >= (splitPane.getHeight() -
                        insets.bottom - getDividerSize()))
                   newLoc = lastLoc;
              else
                   newLoc = insets.top + 40;
              else {
              if (currentLoc >= (splitPane.getWidth() -
                        insets.right - getDividerSize()))
                   newLoc = lastLoc;
              else
                   newLoc = insets.left;
         else {
              if (orientation == JSplitPane.VERTICAL_SPLIT) {
              if (currentLoc == insets.top)
                   newLoc = lastLoc;
              else
                   newLoc = splitPane.getHeight() - getHeight() -
                   insets.top;
              else {
              if (currentLoc == insets.left)
                   newLoc = lastLoc;
              else
                   newLoc = splitPane.getWidth() - getWidth() -
                   insets.left;
         if (currentLoc != newLoc) {
              splitPane.setDividerLocation(newLoc);
              // We do this in case the dividers notion of the location
              // differs from the real location.
              splitPane.setLastDividerLocation(currentLoc);
    } // End of class BasicSplitPaneDivider.LeftActionListener
    </pre>

  • JSplitPane divider not movable

    What would prevent a JSplitPane divider from being movable in its initial state?
    The left pane contains a JTabbedPane, and the right pane contains a JPanel. When the app starts, the left pane is as wide as a single tab, and the divider cannot be dragged. If I click the right arrow on the divider, it expands to the right and then I can drag it.
    I don't observe this behavior in the JSplitPane examples in the tutorials. I figure it must be something about the pane contents that triggers this. But what?
    Braden

    make sure you set the min, max, and preferredsize of both sides of the splitpane

  • JSplitPane Horizontal divider problems

    I have two split panes that each contain a panel, and these split panes are put in another split pane. The problem that I am seeing is the horizontal divider won't move with the mouse drag, but the vertical dividers are fine. Below is poor picture of how the panels are set up:
         |     |          |
         |Panel 1     |     Panel3     |
         |_______ |_______________     |
         |Panel 2     |     Panel4     |     
    Panel 1 and Panel2 are in a split pane called 'leftPane' with a vertical divider which moves up and down fine. Panel3 and Panel4 are in another split pane called 'rightPane' with a vertical divider which is also fine. Now leftpane and rightpane are in a split pane called 'fullpane' with a horizontal divider, and this divider just won't move.
    I have setOneTouchExpandable(true) for all of the split panes, and this works even for the horizontal divider, but the mouse drag on this horizontal divider does nothing. Any suggestions are really appreciated. Thanx.
    The sample code is as follows:
    // Create four panels.
    JPanel pnl1 = new JPanel();
    JPanel pnl2 = new JPanel();
    JPanel pnl3 = new JPanel();
    JPanel pnl4 = new JPanel();
    // Create left Split Pane and right split pane.
    JSplitPane leftPane = new JSplitPane(JSplitPanelVERTICAL_SPLIT, true, pnl1, pnl2);
    JSplitPane rightPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, pnl3, pnl4);
    // Create a pane that contains left pane and right pane.
    JSplitPane fullPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, leftPane, rightPane);
    // Set onetouchexpandable
    leftPane.setOneTouchExpandable(true);
    rightPane.setOneTouchExpandable(true);
    fullPane.setOneTouchExpandable(true);

    I found the problem. The code that I posted was simplified, Actually panel1, panel2, panel3, panel4 had components in them and were using BorderLayout().
    So the horizontal divider couldn't move because the components in the panel were not resizeable. So I fixed this by adding scrollbars to the panels and it seems to work.

  • JSplitPane Movement Problem

    Hi,
    I have a JSPlitPane, on the left side, I have a JTree and on the right, I have a Panel with Toolbars.
    The problem is, when I move the divider to the right, it goes at some point and stick there, this is becuase of Toolbar width, I tried setting the toolbar width on PropertyChange Listener but it seems that propertyChange listener doesn't call at that points. My code is as follows:
    jSplitPane1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
             public void propertyChange(PropertyChangeEvent e) {
                setPanelSize();
                repaint();
    private void setPanelSize() {
          int panelWidth = rightPane.getWidth() - DIFF_BW_PANE_PANEL;
          ideToolBar.setSize(new Dimension(rightPane.getWidth(), ideToolBar.getHeight()));
          ideToolBar.setPreferredSize(new Dimension(rightPane.getWidth(), ideToolBar.getHeight()));
          ideToolBar.setMaximumSize(new Dimension(rightPane.getWidth(), ideToolBar.getHeight()));
          ideToolBar.validate();
          ideToolBar.updateUI();
          System.out.println("ToolBar Width: " + ideToolBar.getSize() + " Panel Size: " + activePanel.getSize());
       }Thanks

    So, if the right panel becomes too narrow to display the whole toolbar, do want it to be cut off? If so, I would try calling  ideToolbar.setMinimumSize(new Dimension(0, ideToolbar.getHeight())); right after you create the toolbar (and leave out all that dynamic sizing code).
    Or just move the toolbar out of the panel--I suspect it shouldn't be there anyway.

  • Center the JSplitPane divider inside a Jframe.

    I am trying to use the JSplitPane class. I want to set the divider in the middle of the Jframe it is in. I have size the Jframe to 500,500 and set the divider to 250. The problem is if you include the title bar of the Jframe then it looks like it is in the right spot but I don�t want to include the title bar I just want the internal part of the frame to be divided in half not the whole Jframe. Any suggestion on how to do that? Also how do you keep the divider in the center when the Jframe is resized. Thanks.

    setDividerLocation(0.5d) should do the job. if you want to set this in the constructor of your container, you should do this after everything else is done, somethinglike
    SwingUtilities.invokeLater(new Runnable()
    public void run()
    xxx.setDividerLocation(0.5d);
    });

  • JSplitPane / JScrollPane Problem

    Hi,
    i use a JSplitPane to divide a navigation-panel (JTree) and a viewer-panel (JEditorPane)
    this works fine with only one problem. the JEditorPane used to display the data has no ScollBars. I�ve already added a JScrollPane instead of the JEditorPane directly but that does not seem to work out.
    how ever, i think this depends on the fact that the JScrollPane (which contains the JEditorPane) is added as the right part of the JSplitPane.
    any ideas how to fix this problem, or how it is caused?
    thx anyway
    cu Errraddicator

    Hi,
    i use a JSplitPane to divide a navigation-panel (JTree) and a viewer-panel (JEditorPane)
    this works fine with only one problem. the JEditorPane used to display the data has no ScollBars. I�ve already added a JScrollPane instead of the JEditorPane directly but that does not seem to work out.
    how ever, i think this depends on the fact that the JScrollPane (which contains the JEditorPane) is added as the right part of the JSplitPane.
    any ideas how to fix this problem, or how it is caused?
    thx anyway
    cu Errraddicator

  • JSplitPane divider too wide on first display

    I have two split panes nested into each other. For the second, inner one, I have a scrollpane with a table on the top and a scrollpane with a textpane on the bottom. When the Frame is shown for the first time, the divider for the inner splitpane is 5 times as wide as it should be.
    What makes things more complicated is that I add the Panel with the splitpane after a user event.
    Any idea,
    Joerg

    Hi,
    I ran into the same problem, and verified that calling "updateUI" on the JSplitPane does fix the problem. I do this just before I call visible on the main frame.
    Like the original poster, I also have a ScrollPane with a Jtable in one of the Split Panels. Maybe something about SplitPanes mixed with scrolly panes and/or tables causes this problem.

  • JSplitPane - Divider only moves to one direction.

    Hi!
    I've got a question concerning a JSplitPane I'm using in my program. I add an objecte to each of my sides. On the left I have a Canvas3d (from Java3d) and on the right a JPanel.
    Now my problem is, that the divider only moves to one direction. I've made it oneTouchExpandable and I've set the dividerLocation to 80%.
    An earlier posting says, I have to set the minimumSize of my components, but my Canvas3d (inherits from a AWT-Canvas) doesn't have the method Canvas.setMinimumSize(Dimension);
    Does anybody see a way out of this? Thanks for any help,
    joerg

    Hi Armyguy:
              To calibrated the screen. Go to all programs find this file. PC Help  &Tools click it and then click on HP Calibrations Utility click yes in next screen. You can also find it this way. In computers program search box type in HP Calibrations Utility  and run it.
            You may also have a bad malware run your Antivirus software scan as well. See if that detects and deletes any thing. If you have Microsoft Security Essential its scan. If not it is free , It detects and moves malware what antivirus do not pickup on Down Loaded from MSN.com. You also want to check your keyboard and see if some thing is pressing the keys. I know that some times if I have something laying on the keyboard it effects the mouse. You can also troubleshoot the mouse in HP Support Assistant . Open up HP Support Assistant click Troubleshoot then click around the computer Cilck on Keyboard and Mouse and other devices tab.  Both mouse and keyboard are listed.

  • JSplitPane divider disappear

    Hi All, I have a problem with my JSplitPane, I have a JSPlitPane with 2 components inside a Frame. This JSPlitPane has a minimumsize set, and a preferredsize set.
    The minimum size works fine if the user tries to move the Divider. The problem comes when I resize the frame. If I resize it too small the divider get lost and I can only see one of the two components.
    In order to see both components again I have to click on the border and the divider appears at the minimumsize, cause there is where the divider has been hidden.
    Does anyone know how to fix this problem? I've tried to set a minimum size to the Frame using the resize listener. That help a little but I can still make the frame too small and I keep loosing the divider.
    Any tip, or solution?
    Thanks...

    make sure you set the min, max, and preferredsize of both sides of the splitpane

  • Changing color of JSplitPane divider

    I have seen many posts on this topic but so far no resolution. What I want is for the two buttons on the divider to be visible but the rest of the divider be invisible. Since my page is white I thought I could set the divider background to white and the problem would be solved. However, no matter which way I use to set the divider background, the buttons disappear as well!
    I have tried
    UIManager.put("SplitPaneDivider.border", BorderFactory.createMatteBorder(5, 5, 5, 5, Color.red));and I have tried extending the BasicSplitPaneUI class :
    public class InvisibleDividerSplitPaneUI extends BasicSplitPaneUI {
         public InvisibleDividerSplitPaneUI() {
            super();
         public BasicSplitPaneDivider createDefaultDivider() {
            return new InvisibleDivider(this);
         class InvisibleDivider extends BasicSplitPaneDivider {
         public InvisibleDivider(BasicSplitPaneUI basicSplitPaneUI) {
                 super(basicSplitPaneUI);
              setLayout(new BorderLayout());
              JPanel jPanel = new JPanel();
              //JButton leftButton = createLeftOneTouchButton();
              //JButton rightButton = createRightOneTouchButton();
              //jPanel.add(leftButton);
              //jPanel.add(rightButton);
              jPanel.setBackground(PILFColorThemes.formFieldBackgroundColor);
              jPanel.setBorder(new LineBorder(PILFColorThemes.formFieldBackgroundColor));
              add(jPanel);
              setBorder(new LineBorder(PILFColorThemes.formFieldBackgroundColor));
         public int getDividerSize() {
              return 8;
    In both cases the divider color is changed but the buttons are gone!  Any one have an idea?!
    Thanks so much!

    I have seen many posts on this topic but so far no resolution. What I want is for the two buttons on the divider to be visible but the rest of the divider be invisible. Since my page is white I thought I could set the divider background to white and the problem would be solved. However, no matter which way I use to set the divider background, the buttons disappear as well!
    I have tried
    UIManager.put("SplitPaneDivider.border", BorderFactory.createMatteBorder(5, 5, 5, 5, Color.red));and I have tried extending the BasicSplitPaneUI class :
    public class InvisibleDividerSplitPaneUI extends BasicSplitPaneUI {
         public InvisibleDividerSplitPaneUI() {
            super();
         public BasicSplitPaneDivider createDefaultDivider() {
            return new InvisibleDivider(this);
         class InvisibleDivider extends BasicSplitPaneDivider {
         public InvisibleDivider(BasicSplitPaneUI basicSplitPaneUI) {
                 super(basicSplitPaneUI);
              setLayout(new BorderLayout());
              JPanel jPanel = new JPanel();
              //JButton leftButton = createLeftOneTouchButton();
              //JButton rightButton = createRightOneTouchButton();
              //jPanel.add(leftButton);
              //jPanel.add(rightButton);
              jPanel.setBackground(PILFColorThemes.formFieldBackgroundColor);
              jPanel.setBorder(new LineBorder(PILFColorThemes.formFieldBackgroundColor));
              add(jPanel);
              setBorder(new LineBorder(PILFColorThemes.formFieldBackgroundColor));
         public int getDividerSize() {
              return 8;
    In both cases the divider color is changed but the buttons are gone!  Any one have an idea?!
    Thanks so much!

  • JSplitPane resize problem (not a minimum size problem though)

    I created a JSplitPane and put a JPanel in both the top and bottom sides. This JSplitPane is in the center section of a BorderLayout of a JFrame. The minimum sizes are set and I can move the divider bar all I want. Instead, I am having trouble resizing the window and having the divider bar becoming shorter. When I resize the window, the width of the images dont become smaller even though they have a minimum size set to a minimal size and there is space in the panels that can be reduced.
    Here is the code that I am playing with to get this to work. Any ideas how to get this to work? It works in the SwingSet2 Demo, but there is so much extra junk in there that I cant determine the differences with what I'm doing.
    Thanks,
    J.R.
    import java.awt.*;
    import javax.swing.*;
    public class SplitPaneJFrame extends JFrame {
    JPanel statsPanel = new JPanel();
    JPanel northPanel = new JPanel();
    JPanel southPanel = new JPanel();
    JSplitPane splitPane;
    public SplitPaneJFrame () {
    setupGUI();
    private void setupGUI() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setSize(screenSize.width, screenSize.height - 64);
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    JPanel p1 = new JPanel();
    p1.setMinimumSize(new Dimension(100,100));
    p1.setPreferredSize(new Dimension(500,250));
    p1.setBackground(Color.yellow);
    p1.add(new Button("This is a button for the top area"));
    JPanel p2 = new JPanel();
    p2.setMinimumSize(new Dimension(100,100));
    p2.setPreferredSize(new Dimension(500,250));
    p2.setBackground(Color.red);
    p2.add(new Button("This is a button for the bottom area"));
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, northPanel, southPanel);
    splitPane.setOneTouchExpandable(true);
    northPanel.setLayout(new BorderLayout());
    northPanel.setMinimumSize(new Dimension(100,100));
    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
    panel.setPreferredSize(new Dimension((int)Math.min(1012, getSize().width * .75), (int)(getSize().height * 0.75)));
    panel.setMinimumSize(new Dimension(100,100));
    panel.add(p1);
    northPanel.add(panel);
    southPanel.setLayout(new BorderLayout());
    southPanel.setMinimumSize(new Dimension(100,100));
    southPanel.add(p2);
    splitPane.setDividerLocation(0.75);
    c.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
    c.setBackground(Color.white);
    JPanel jp = new JPanel();
    jp.add(splitPane);
    c.add(BorderLayout.CENTER, jp);
    setVisible(true);
    public static void main(String args []) {
    new SplitPaneJFrame();

    Hmm. Ok, that was dumb on my part :-) Sometimes you just need a second set of eyes.
    Any Idea why, after I make the fix, the top panel does not resize at all? The bottom one does, but the inner panels of the top do not. I added a second panel to the top and it flowed under the first one panel (p1) as the outter panel (northPanel) resized, but the inner panel stays the same size regardless of how much I narrow the window.
    J.R.

  • JSplitPane divider does not change cursor in JDialog

    Hello,
    I am working with a JSplitPane added to a JDialog and when
    I try to move the divider the mouse cursor does not change
    to the resize cursor. If I add the JSplitPane to a JFrame it works
    ok. Is this a bug???
    Try the following code:
    JDialog d = new JDialog();
    d.add(new JSplitPane());
    d.setSize(640,480);
    d.setVisible(true);
    Thanks for any help!

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Testing
      JDialog d = new JDialog();
      public Testing()
        JSplitPane sp = new JSplitPane();
        d.add(sp);
        sp.setUI(new MyUI());
        d.setSize(640,480);
        d.setVisible(true);
      class MyUI extends javax.swing.plaf.metal.MetalSplitPaneUI
        public javax.swing.plaf.basic.BasicSplitPaneDivider createDefaultDivider()
          javax.swing.plaf.basic.BasicSplitPaneDivider divider = super.createDefaultDivider();
          divider.addMouseListener(new MouseAdapter(){
            public void mouseEntered(MouseEvent me){
              d.setCursor(new Cursor(Cursor.E_RESIZE_CURSOR));
            public void mouseExited(MouseEvent me){
              d.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          return divider;
      public static void main(String[] args){new Testing();}
    }Message was edited by:
    Michael_Dunn
    [EDIT]
    will also need to add Cursor code for mouseDragged()

  • JSplitPane update problem

    If someone could help, I would greatly appreciate it. The problem involves a JSplitPane, which is a Tab within a JTabbedPane, where
    the TopComponent (which contains a JComboBox) passes an argument to the Class that represents the BottomComponent to display detail information. The Class(Mgmt_Contact - BottomComponent) is
    receiving the parameter and processes but the data does not display. I have SOP messages that indicate the data is being formatted correctly. I'm really confused and desperately need help. The problem deals with addressing the BottomComponent of the JSplitPane from the Class that represents the TopComponent.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Home extends JFrame{
    private JTabbedPane tabbedPane;
    public Home(){
    super("The Travel Agency Model");
    addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e){
    system.exit(0);
    }); // end of WindowListener
    tabbedPane = new JTabbedPane(SwingConstants.LEFT);
    tabbedPane.setBackground(Color.blue);
    tabbedPane.setForeground(Color.white);
    populateTabbedPane();
    getContentPane().add(tabbedPane);
    buildMenu();
    } // end of constructor
    private void buildMenu(){
    JMenuBar mb = new JMenuBar();
    JMenu menu = new JMenu("File");
    JMenuItem item = new JMenuItem("Exit");
    item.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
    System.exit(0);
    }); //end of addActionListener
    menu.add(item);
    mb.add(menu);
    setJMenuBar(mb);
    } // end of buildMenu
    // create tabs with titles
    private void populateTabbedPane(){
    tabbedPane.addTab("Management", null,
    new Management(), "Select the Management ");
    } // end of populateTabbedPane
    public static void main(String[] args){
    Home dl = new Home();
    dl.pack();
    dl.setSize(800, 620);
    dl.setBackground(Color.white);
    dl.setVisible(true);
    // end of Home class
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Management extends JPanel implements ChangeListener{
    private JTabbedPane propPane;
    public Management(){
    propPane = new JTabbedPane(SwingConstants.TOP);
    propPane.setSize(795, 550);
    propPane.addChangeListener(this);
    populateTabbedPane();
    add(propPane);
    } // end of constructor
    // create tabs with titles
    private void populateTabbedPane(){
    propPane.addTab("Management", null, new Mgmt(), "Management");
    propPane.addTab("Management Contact", null, new Management_Contact(),
    "Management Contact");
    } // end of populateTabbedPane
    public void stateChanged(ChangeEvent e){
    System.out.println("\n\n ****** Management.java " + propPane.getSelectedIndex() + " " + propPane.getTabPlacement());
    public static void main(String[] args){
    Home dl = new Home();
    dl.pack();
    dl.setSize(800, 620);
    dl.setBackground(Color.white);
    dl.setVisible(true);
    } // end of Management class
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.io.*;
    public class Mgmt extends JPanel{
    public Mgmt() {
    } // end of Mgmt class
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Management_Contact extends JPanel {
    Mgmt_Class mgmt = null;
    Mgmt_Contact mgmtContact = null;
    public Management_Contact() {
    JSplitPane split = new JSplitPane();
    split.setOrientation(JSplitPane.VERTICAL_SPLIT);
    Mgmt_Header hdr = new Mgmt_Header();
    split.setTopComponent(hdr);
    Mgmt_Contact mgmtContact = new Mgmt_Contact();
    JScrollPane scrollPane = new JScrollPane(mgmtContact,
    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setPreferredSize(new Dimension(650,300));
    split.setBottomComponent(scrollPane);
    add(split);
    } // end of Management class
    import java.util.Vector;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Mgmt_Header extends JPanel implements ActionListener{
    private JComboBox cmbMgmt;
    private JTextField txtMgmtAddr1;
    private JTextField txtMgmtAddr2;
    private JPanel pWork;
    private Box vertBox;
    private Box topBox;
    private Box midBox;
    private Box botBox;
    private Mgmt_Class mClass = null;
    private Mgmt_Contact cnt = null;
    Vector mgmtVct = null;
    public Mgmt_Header(){
    vertBox = Box.createVerticalBox();
    topBox = Box.createHorizontalBox();
    midBox = Box.createHorizontalBox();
    botBox = Box.createHorizontalBox();
    mClass = new Mgmt_Class();
    mgmtVct = new Vector();
    cmbMgmt = new JComboBox();
    cmbMgmt.addItem(" ");
    mgmtVct = mClass.bldMgmtHeader();
    for (int x1=0; x1<mgmtVct.size() ;x1++ )
    mClass = (Mgmt_Class)mgmtVct.get(x1);
    cmbMgmt.addItem(mClass.getManagementName());
    System.out.println("MgmtHeader " + mgmtVct.size() + " " + cmbMgmt.getItemCount());
    cmbMgmt.setEditable(false);
    cmbMgmt.setBackground(Color.white);
    cmbMgmt.setName("cmbMgmt");
    cmbMgmt.setPreferredSize(new Dimension(250,27));
    cmbMgmt.setFont(new Font("Times-Roman",Font.PLAIN,12));
    cmbMgmt.addActionListener(this);
    pWork = new JPanel();
    pWork.setLayout(new FlowLayout(FlowLayout.CENTER));
    pWork.setBorder(BorderFactory.createTitledBorder(" Select Management Name or Enter Code "));
    pWork.add(new JLabel("Name: "));
    pWork.add(cmbMgmt);
    topBox.add(pWork);
    txtMgmtAddr1 = new JTextField("Address line 1",15);
    txtMgmtAddr1.setEditable(false);
    txtMgmtAddr2 = new JTextField("Address line 2",15);
    txtMgmtAddr2.setEditable(false);
    midBox.add(midBox.createVerticalStrut(10));
    botBox.add(new JLabel("Address:"));
    botBox.add(topBox.createHorizontalStrut(15));
    botBox.add(txtMgmtAddr1);
    botBox.add(topBox.createHorizontalStrut(15));
    botBox.add(txtMgmtAddr2);
    vertBox.add(topBox);
    vertBox.add(midBox);
    vertBox.add(botBox);
    add(vertBox);
    } // end of constructor
    public void actionPerformed(ActionEvent evt){
    if (evt.getSource() instanceof JComboBox){
    if (((JComboBox)evt.getSource()).getName() == "cmbMgmt"){
    int sel = ((JComboBox)evt.getSource()).getSelectedIndex();
    System.out.println("ActionListener " + sel + " " +
    ((JComboBox)evt.getSource()).getItemAt(sel) + " " +
    cmbMgmt.getItemAt(sel));
    Mgmt_Class mClass = (Mgmt_Class)mgmtVct.get(sel - 1);
    System.out.println("From Vector " + mClass.getAddress1() + " " +
    mClass.getAddress2() + " " + mClass.getManagementCode());
    txtMgmtAddr1.setText(mClass.getAddress1());
    txtMgmtAddr2.setText(mClass.getAddress2());
    System.out.println("\n\nListener " + ((JComboBox)evt.getSource()).getSelectedItem() + " " + (((JComboBox)evt.getSource()).getSelectedIndex()) );
    int mCode = mClass.getManagementCode();
    Mgmt_Contact cnt = new Mgmt_Contact(mCode);
    System.out.println("\n After new Mgmt_Contact constructor");
    } // end of JComboBox
    } // end of actionPerformed
    } // end of Mgmt_Header class
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.io.*;
    public class Mgmt_Contact extends JPanel{
    private Mgmt_Contact_Class contact = null;
    private JTextField txtFName = null;
    private JTextField txtLName = null;
    private JTextField txtAddr1 = null;
    private JTextField txtAddr2 = null;
    private JButton btnUpd = null;
    private JButton btnNew = null;
    private JButton btnDel = null;
    private JButton btnNext = null;
    private JButton btnPrior = null;
    private JPanel cntct = null;
    private JPanel pWork = null;
    private JPanel pWest = null;
    private JPanel pSouth = null;
    private JPanel pCenter = null;
    public Mgmt_Contact() {
    System.out.println("\n MgmtContact default constructor");
    contact = new Mgmt_Contact_Class();
    bldPage();
    System.out.println("\n ******* After bldPage() routine");
    public Mgmt_Contact(int mCode) {
    System.out.println("\n MgmtContact second constructor " + mCode);
    Vector mgmtVct = new Vector();
    contact = new Mgmt_Contact_Class();
    mgmtVct = contact.bldMgmtContactTbl(mCode);
    contact =(Mgmt_Contact_Class)mgmtVct.get(0);
    System.out.println("\n ******* Management Contact Table *** " + contact.getFirstName());
    bldPage();
    System.out.println("\n ******* After bldPage() routine");
    public void bldPage(){
    System.out.println("\n MgmtContact bldPage ");
    cntct = new JPanel();
    cntct.setLayout(new BorderLayout());
    pWest = new JPanel();
    pWest.setLayout(new GridLayout(0,1));
    pCenter = new JPanel();
    pCenter.setLayout(new GridLayout(0,1));
    pSouth = new JPanel();
    pWork = new JPanel();
    pWork.setLayout(new FlowLayout(FlowLayout.LEFT));
    pWest.add(new JLabel("First :"));
    txtFName = new JTextField(15);
    txtFName.setText(contact.getFirstName());
    System.out.println("\n First Name " + txtFName.getText() + " " +
    contact.getFirstName());
    txtFName.setPreferredSize(new Dimension(200,27));
    pWork.add(txtFName);
    pWork.add(new JLabel("Last :"));
    txtLName = new JTextField(15);
    txtLName.setText(contact.getLastName());
    txtLName.setPreferredSize(new Dimension(200,27));
    pWork.add(txtLName);
    pCenter.add(pWork);
    pWork = new JPanel();
    pWork.setLayout(new FlowLayout(FlowLayout.LEFT));
    pWest.add(new JLabel("Address :"));
    txtAddr1 = new JTextField(15);
    txtAddr1.setText(contact.getAddress1());
    txtAddr1.setPreferredSize(new Dimension(200,27));
    pWork.add(txtAddr1);
    pWork.add(new JLabel(" "));
    txtAddr2 = new JTextField(15);
    txtAddr2.setText(contact.getAddress2());
    txtAddr2.setPreferredSize(new Dimension(200,27));
    pWork.add(txtAddr2);
    pCenter.add(pWork);
    pWork = new JPanel();
    pWork.setLayout(new FlowLayout(FlowLayout.LEFT));
    btnNew = new JButton(" Add ");
    btnUpd = new JButton("Update");
    btnDel = new JButton("Delete");
    btnNext = new JButton(" Next ");
    btnPrior = new JButton(" Prior ");
    pSouth.add(btnNew);
    pSouth.add(btnUpd);
    pSouth.add(btnDel);
    pSouth.add(btnNext);
    pSouth.add(btnPrior);
    cntct.add("West", pWest);
    cntct.add("Center", pCenter);
    cntct.add("South", pSouth);
    add(cntct);
    } // end of Mgmt_Contact class

    Repaint/revalidate will work but what I didn't explain is that the components on each side are also containers and the user events for the contained, non-opaque components are handled transparently to my code.
    Is there a way to get the JSplitPane to automatically update both sides so that I don't have to catch all possible user events? (Scrolling, key punching, tree expanding, button pressing, etc).
    OR
    How can I detect that the split pane is updating one side so I can run repaint/revalidate on the other side?
    Thanks!

Maybe you are looking for