File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "scrollpane and panels" Watch "scrollpane and panels" New topic
Author

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);
a.setHorizontalAlignment(JTextField.RIGHT);
p.add(a);


// adding panel p to scrollpane
JScrollPane scroll = new JScrollPane(p,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scroll.setBounds(120,0,100,200);

// scrollpane is added to panel pp
pp.add(scroll);


//add panel pp to frame
c.add(pp);
fr.setSize(250,200);
fr.show();
Amol Desai
Ranch Hand

Joined: Jan 29, 2003
Posts: 82
Hi,
Your code works after adding the following to JScrollPane
scroll.setPreferredSize(new Dimension(100,100));
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: scrollpane and panels
 
Similar Threads
JTable rows are getting visible in the middile of the JFrame only
Problem with JTree inside JScrollPane inside JPanel
how to add scrollpane for a jpanel with null layout manager.
JPanel scroll bar
JPanel on JScrollBar possible?