We help IT Professionals succeed at work.

Dragging JScrollPane problem.

paperless
paperless asked
on
HI !

In my GUI aplication, I have divided my GUI into two part using JSplitPane. on left have a JTree an on right side have JTabbedPanel's .

Dragging scrollpane to right side is a prblem if the Panel where I have used Boxes.

How to solve the problem.

take care
Comment
Watch Question

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
19 questions asked
only 6 questions graded

Author

Commented:
yA BUT I will grade it if get proper answer..

see the question and evaluate the answer............

its open for I can still grade them provided u are satisfied by the expectation and the answer I got..

take care
paperless
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
If your not satisfied with the answer then why aren't you asking clarifying questions.
In some case, experts have asked u for clarification of the problem and you haven't replied.

Commented:
dear paperless:

Usually if you aren't satisfied with the answers just ask again in the same thread and tell why you aren't satisfied.   In extreme cases when nobody cares to answer your question, you can have your question deleted by the Community Support and get back the points.

It is bad style not to accept any comment as an answer just because you weren't satisfied. Experts want feedback whether their answer are good or not. In the long term you should close all questions because the experts can look at your profile and decide that they don't want to help you because you don't close your questions.

What to do now? Go to your own profile and close all open questions one by one.

Author

Commented:

Ok thanks for reminding me to do my home work first.

Let me first reply properly to earlier questions openend by me.

and then I come back to this one.

take care,
paperless

Author

Commented:
Hi !

So now you guys can start answering the answerws to my  problem now, that I have cleared all pendings???

CERTIFIED EXPERT

Commented:
objects and dnoelpp are cruel :-) As a result of this disscusion I got two "Good answer" notifications by paperless!!! Poor paperless!
Why I(anyone) need these expert points by the way?

So, In my opinion you have component with setMinimumSize(new Dimension(some big value,some)) in your right side Panel....

Regards to all participants in this question!!!
Especially to objects! :-)

Best Regards,
Valeri

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
I don't understand how you have divided your GUI with a JScrollPane.
Can u pls explain?

Author

Commented:
HI !

Valeri you mean to suggest I put setMinimumSize(), to the right Panels or ??

I have devided like this oh sorry I have used JSplitPane  to devide it vertically .

sorry for inconvenience........

take care
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
So what exactly is the problem with the ScrollPane?

Author

Commented:
I have put up both panels into JScrollPane.

At some point I have dragged he right panel towardss leftt. for proper view .

NOw I want the proper view of left side so I try to drag it righ now.  But because in the right Panel I have used Boxes and GridLayout, this is now able to do.

and thouh right side tree is in JScrollPAne but for proper view I need to drag it right.

Author

Commented:
I have put up both panels into JScrollPane.

At some point I have dragged he right panel towardss leftt. for proper view .

NOw I want the proper view of left side so I try to drag it righ now.  But because in the right Panel I have used Boxes and GridLayout, this is now able to do.

and thouh right side tree is in JScrollPAne but for proper view I need to drag it right.
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
So your problem is with the layout of your components on the right side?

Author

Commented:
Ya, and because of this loosing flexibility in movement.

So if user wants to move Panes right or left its problem.
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
Well can you post your layout code?
CERTIFIED EXPERT

Commented:
Yes... Some of your components(in the right pane) must have setMaximumSize(new Dimension(x, y)); or setPreferredSize(new Dimension(x, y));
Take a look at the biger components and make them smaller... Do it in your Init() function.
I hope it will help you!!!
Can you post your layout code?

Best Regards,
Valeri

Author

Commented:
Layout of Panel ?? wich is causing problem ??


    private void createMailPane(){
      JPanel mailSelPane = new JPanel(new GridLayout(3, 2, 0, 20));      
      mailSelPane.setBorder(new TitledBorder
          (new LineBorder(Color.black), "Event Notification" ));

      JLabel jLab = new JLabel( " Enter Mobile No.");
//       textVal = "Don't change this text if SMTP IP is"+
//         "valid in config file";
      tF = new JTextField();
      tF.setText("Not Available In This Version!!");
//      tF.setText("");
        tF.setEditable(false);
      JLabel jLabs = new JLabel(" Enter E-Mail Id");
      tFs = new JTextField();

      JLabel pagerLabs = new JLabel(" Enter Pager No.");
      JTextField pagerText = new JTextField();
      pagerText.setText("Not Available In This  Version!!");
//      pagerText.setText("");
      pagerText.setEditable(false);
      mailSelPane.add(jLabs);
      mailSelPane.add(tFs);
      mailSelPane.add(jLab);//, BorderLayout.NORTH);
      mailSelPane.add(tF);
      mailSelPane.add(pagerLabs);
      mailSelPane.add(pagerText);

      JPanel eventPane = new JPanel(new GridLayout(5, 2));
      eventPane.setBorder(new TitledBorder
          (new LineBorder(Color.black), "Events" ));

      Box nodeBox = Box.createHorizontalBox();
      mail = new JCheckBox("                    ");      
      JCheckBox sms = new JCheckBox( "                          ");      
      sms.setEnabled(false);
      JCheckBox pager = new JCheckBox(" ");      
      pager.setEnabled(false);
      nodeBox.add(mail);
      nodeBox.add(sms);
      nodeBox.add(pager);

      Box ccmBox = Box.createHorizontalBox();
      //JCheckBox
      ccmmail = new JCheckBox("                    ");      
      JCheckBox ccmsms = new JCheckBox( "                          ");
      ccmsms.setEnabled(false);      
      JCheckBox ccmpager = new JCheckBox(" ");      
      ccmpager.setEnabled(false);
      ccmBox.add(ccmmail);
      ccmBox.add(ccmsms);
      ccmBox.add(ccmpager);


      Box logBox = Box.createHorizontalBox();
      JCheckBox logmail = new JCheckBox("                    ");      
      logmail.setEnabled(false);
      JCheckBox logsms = new JCheckBox( "                          ");
      logsms.setEnabled(false);      
      JCheckBox logpager = new JCheckBox(" ");      
      logpager.setEnabled(false);
      logBox.add(logmail);
      logBox.add(logsms);
      logBox.add(logpager);

      Box reBox = Box.createHorizontalBox();
      JCheckBox remail = new JCheckBox("                    ");      
       remail.setEnabled(false);
      JCheckBox resms = new JCheckBox( "                          ");      
      resms.setEnabled(false);
      JCheckBox repager = new JCheckBox(" ");      
      repager.setEnabled(false);
      reBox.add(remail);
      reBox.add(resms);
      reBox.add(repager);


      nodeO = new JCheckBox("Ovent");
      nodeO.addItemListener(new NodeCheckBoxListener());

      instO = new JCheckBox("Event");
      instO.addItemListener(new InstCheckBoxListener());

      restartO = new JCheckBox(" Exceeds (Not Avail!)");
      restartO.setEnabled(false);
      restartO.addItemListener(new RestartCheckBoxListener());
      logSizeExceedO = new JCheckBox("Message");
      logSizeExceedO.setEnabled(false);
      logSizeExceedO.addItemListener(new LogCheckBoxListener());


      Box evtBox = Box.createHorizontalBox();
      Box typeBox = Box.createHorizontalBox();
      JLabel eventNot = new JLabel("Event Available to subscribe");
      JLabel mailLabel = new JLabel("Get Mail         ");
      JLabel pagerLabel = new JLabel("Get Pagerbeep      ");
      JLabel smsLabel = new JLabel("   SMS");
      evtBox.add(eventNot);
      typeBox.add(mailLabel);
      typeBox.add(pagerLabel);
      typeBox.add(smsLabel);
      

      eventPane.add(evtBox);
      eventPane.add(typeBox);
//       eventPane.add(not
      eventPane.add(nodeO);
      eventPane.add(nodeBox);
      eventPane.add(instO);
      eventPane.add(ccmBox);
      eventPane.add(restartO);
      eventPane.add(logBox);
      eventPane.add(logSizeExceedO);
      eventPane.add(reBox);
      Box buttonBox = Box.createHorizontalBox();

      JButton jB = new JButton("Subscribe");
      jB.addActionListener(new SubscribeMailAction());

      JButton cancel = new JButton("Unsubscribe");
      cancel.addActionListener(new CancelAction());

      buttonBox.add(jB);
      buttonBox.add(cancel);

      add(mailSelPane, BorderLayout.CENTER);
      add(eventPane, BorderLayout.NORTH);
      add(buttonBox, BorderLayout.SOUTH);
    }

Author

Commented:
I haven't used anywhere set Preferred sixe or Max or minimum size  other then

Top level JFrane size as 600, 450.
CERTIFIED EXPERT

Commented:
Why do you have parts of code, such like that ?

>>>>>>>>>>>>>
Box nodeBox = Box.createHorizontalBox();
     mail = new JCheckBox("                    ");    
     JCheckBox sms = new JCheckBox( "                          ");    
     sms.setEnabled(false);
     JCheckBox pager = new JCheckBox(" ");    
     pager.setEnabled(false);
     nodeBox.add(mail);
     nodeBox.add(sms);
     nodeBox.add(pager);
<<<<<<<<<<<<<<

Do you have the same problem, if the strings(the empty strings) are not too long ?
GridLayout retains the width ot the components, so in my opinion that's the reason for the problem.

Best Regards,
Valeri

Author

Commented:
MAy be I didn't try that, but in the current scenario, even dragging to expand the Panel doesn't wotk Properly

..
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
Yes I agree with Valeri, the GridLayout's going to resize each grid component to the same size.

Author

Commented:
I found one relation.

In one JTabbedPane I have two JPanels.

In one Panel I use GridLayout and boxes and JScrollPane seems to behave properly.

IN other I have again three Panel with GridLayout but in one Grid I have JCheckBox with a long Strings, so that it is not fully visible if opened to default. (No problem).

After openeing this JScrollPane becomes unscrollable.  Even when I go back to previosu Panel, it also doesn't scrolls.  But in other JTabbedPAne
where I have again simple GridLyout and Boxes it behaves fine.
So that now if I want to expand or contract the Panel I have to come to this Panel.

how to solve this.

CERTIFIED EXPERT
Commented:
Try with
setMinimumSize(new Dimension(x, y)); and
setPreferredSize(new Dimension(x, y)); of your JScrollPane. I can be more detailed, but the code you posted is not enough...

Best regards,
Valeri

Author

Commented:
Over the Panel that contains this Layout.

Once I click on this Panel, and I swicth to other Panel scrolling the Bar doesn't work properly.  

So I should call this over the parent JTabbedPane or in all other Panels.

Author

Commented:
Yo it solved the problem, once I am calling

setMinimumSize(new Dimension(0, 0))

on the Panels, which were giving problem, this problem is no more there.

take care
paperless

Explore More ContentExplore courses, solutions, and other research materials related to this topic.