Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JScrollPane

Reply
Thread Tools

JScrollPane

 
 
Thorsten Kiefer
Guest
Posts: n/a
 
      03-20-2008
Hi,
I need scroll pane which does not resize its child.
I.e. the child must always keep its preferred size.
If the scroll pane it bigger than the child, the child should
be aligned to the scroll pane's center.

Is something like that available ?

Best wishes
Thorsten

 
Reply With Quote
 
 
 
 
Alex.From.Ohio.Java@gmail.com
Guest
Posts: n/a
 
      03-20-2008
On Mar 20, 7:06 am, Thorsten Kiefer <(E-Mail Removed)> wrote:
> Hi,
> I need scroll pane which does not resize its child.
> I.e. the child must always keep its preferred size.
> If the scroll pane it bigger than the child, the child should
> be aligned to the scroll pane's center.
>
> Is something like that available ?
>
> Best wishes
> Thorsten


Just add additional container inside JScrollPane:

public class GUI {
public static void main(String[] args) {
JFrame frame=new JFrame();
frame.setSize(500, 400);
JButton button=new JButton("Click me");
button.setPreferredSize(new Dimension(200, 40));
JPanel panel=new JPanel();
panel.add(button);
JScrollPane scrollableArea = new JScrollPane(panel);
frame.add(scrollableArea);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
frame.setVisible(true);
}
}

Alex.
http://www.myjavaserver.com/~alexfromohio/
 
Reply With Quote
 
 
 
 
Thorsten Kiefer
Guest
Posts: n/a
 
      03-20-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> On Mar 20, 7:06 am, Thorsten Kiefer <(E-Mail Removed)> wrote:
>> Hi,
>> I need scroll pane which does not resize its child.
>> I.e. the child must always keep its preferred size.
>> If the scroll pane it bigger than the child, the child should
>> be aligned to the scroll pane's center.
>>
>> Is something like that available ?
>>
>> Best wishes
>> Thorsten

>
> Just add additional container inside JScrollPane:
>
> public class GUI {
> public static void main(String[] args) {
> JFrame frame=new JFrame();
> frame.setSize(500, 400);
> JButton button=new JButton("Click me");
> button.setPreferredSize(new Dimension(200, 40));
> JPanel panel=new JPanel();
> panel.add(button);
> JScrollPane scrollableArea = new JScrollPane(panel);
> frame.add(scrollableArea);
> frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
> frame.setVisible(true);
> }
> }
>
> Alex.
> http://www.myjavaserver.com/~alexfromohio/


Cool, Thanks !!!
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      03-20-2008
On Thu, 20 Mar 2008 12:06:27 +0100, Thorsten Kiefer
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone who
said :

>I need scroll pane which does not resize its child.
>I.e. the child must always keep its preferred size.


You could use setPreferredSize setMinimumSize setMaximumSize on the
child and see if it honours your request.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I nest a JEditorPane inside a JScrollPane inside a JPanel? Mike Java 5 12-02-2003 01:45 PM
Problem with JList, DefaultListModel and JScrollPane Tobi Krausl Java 0 11-12-2003 11:20 AM
change jscrollpane bar? soni29 Java 0 08-21-2003 07:39 PM
TextArea in JScrollPane extends, not shrinks Miguel De Anda Java 0 08-13-2003 08:40 PM
JScrollPane scroll to top Richard Trahan Java 0 07-26-2003 04:01 PM



Advertisments