• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Panel in ScrollPane

 
Trailboss
Posts: 23888
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I made a lovely panel that is rather large. I want to put it in a ScrollPane, but no dice.
What's wrong? Do I need to somehow attach it to a canvas or something?
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can add the panel to a scrollpane
than on to the container directly.
 
paul wheaton
Trailboss
Posts: 23888
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I took my panel and converted it to a canvas-like thing and now it seems to work.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same problem with big panel putting into a scrollpane. It doesn't work (at least with me) as other componets (like textarea) works with scrollpane. Is there any way of doing this?
 
paul wheaton
Trailboss
Posts: 23888
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know that ScrollPane doesn't work right under IE. I ended up making my own scrolling object.
Also, a panel won't show up unless you specify its size.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't tried this under IE, but the following code works fine for me using JDK 1.2.2 for Windows:
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i had a similiar proplem recently. i was putting a large JPanel inside a JScrollPane, and the adding the scrollpane to another JPanel. When the window was too small the scrollbars were showing, i think, but they weren't visible, because the outmost jpanel was too small (since it wasnt in a scrollpane)
It took me some time to figure out what was wrong... so i hope this is helping
// Jesper
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jim,
Your following code works fine -
import java.awt.*;
import javax.swing.*;
public class Test extends JFrame {
public Test() {
JLabel bigLabel = new JLabel("Really Big Label");
JLabel.getFont().deriveFont(200.0F));
JPanel panel = new JPanel();
panel.add(bigLabel);
JScrollPane scrollPane = new JScrollPane(panel);
getContentPane().add(scrollPane);
setSize(new Dimension(200, 200));
setVisible(true);
}

public static void main(String[] s) {
new Test();
}
}
What about if you add the following line in the code:
panel.setLayout(null);
No more scrollpanel when I add that line in my program.
Any idea?
(but it works when you set other type of layout)
 
It will give me the powers of the gods. Not bad for a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic