File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes scrollpane and panels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "scrollpane and panels" Watch "scrollpane and panels" New topic

scrollpane and panels

vidya archana
Ranch Hand

Joined: Oct 29, 2002
Posts: 36
can anyone please help me out in this problem?
i cant giev a scoll to the panel. and even this simple code is not working..
Please help.
JFrame fr = new JFrame();
Container c = fr.getContentPane();

JPanel p = new JPanel(null);
JPanel pp = new JPanel();

// adding a textfield to panel p
JTextField a = new JTextField();
a.setBounds(80, 50, 250, 28);

// adding panel p to scrollpane

// scrollpane is added to panel pp

//add panel pp to frame
Amol Desai
Ranch Hand

Joined: Jan 29, 2003
Posts: 82
Your code works after adding the following to JScrollPane
scroll.setPreferredSize(new Dimension(100,100));
It is sorta covered in the JavaRanch Style Guide.
subject: scrollpane and panels
Similar Threads
JPanel on JScrollBar possible?
how to add scrollpane for a jpanel with null layout manager.
JTable rows are getting visible in the middile of the JFrame only
JPanel scroll bar
Problem with JTree inside JScrollPane inside JPanel