Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

scrollpane and panels

 
vidya archana
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Your code works after adding the following to JScrollPane
scroll.setPreferredSize(new Dimension(100,100));
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic