• Post Reply Bookmark Topic Watch Topic
  • New Topic

Having a little problem bringing up a scrollbar  RSS feed

 
Meghna ks
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys
I'm having a little problem here. I've designed a bean with a Scrollpane and a panel inside it. Labels and Textfields are added to the panel continuosly, and I've currently set the Panel's layout to null. In one of the cases for the TextFields, I've added a mouseclicked event wherein a calendar pops up inside the bean when the user clicks inside the TextField which has the date. Now, the problem is that initially, the panel's layout was Gridlayout, but when I do the same, all the components get sized to that of a calendar and it looks bad and now that the layout is null, the scrollbar's not appearing. If I happen to size the calendar small , then the user will not be able to select the date. Please help me with this.
Thanks
Meghna
//===============================================================
setLayout(new BorderLayout(0,0));
//setSize(290,115);
setSize(0,0);
JScrollPane1.setAutoscrolls(true);
JScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
JScrollPane1.setOpaque(true);
add(BorderLayout.CENTER,JScrollPane1);
JPanel1.setAutoscrolls(true);
JPanel1.setLayout(null);
JScrollPane1.getViewport().add(JPanel1);
JPanel1.setBounds(0,0,1,1);
//JScrollPane1.setBounds(0,0,430,200);
//JPanel1.setLayout(new GridLayout(0,2,5,5));
//JPanel1.setBounds(0,0,427,197);
//}}
//===============================================================
cclass SymMouse extends java.awt.event.MouseAdapter
{
public void mouseClicked(java.awt.event.MouseEvent event)
{
Object object = event.getSource();
if (object == cal)
cal_mouseClicked(event);
else if(object == mask1)
mask1_mouseClicked(event);
}
}
//===============================================================void cal_mouseClicked(java.awt.event.MouseEvent event)
{
// to do: code goes here.
String str = cal.getDate();
mask1.setText(str);
cal.setVisible(false);
}
//===============================================================void mask1_mouseClicked(java.awt.event.MouseEvent event)
{
if(mask1.isEditable() == true)
{
cal.setVisible(true);
cal.setSize(200, 150);
cal.setLocation(this.getX(), this.getY());
cal.repaint();
cal.validate();
}
else
return;
}
}//End Class
//===============================================================
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Setting a LayoutManager to null is a really bad idea. Then you have to manage the zillion or so things that the LayoutManager was taking care of for you (as you found out - you have to deal with the resizing etc )
I think that the trick here is to learn to manipulate lots of panels and etc. to get the look that you WANT without giving up the benefits provided by the managers. I don't know what look you want, but try setting panel1 to FlowLayout which will get rid of that "calendar" look.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!