aspose file tools
The moose likes Swing / AWT / SWT and the fly likes ScrollPane is always a problem !!! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "ScrollPane is always a problem !!!" Watch "ScrollPane is always a problem !!!" New topic
Author

ScrollPane is always a problem !!!

Meghna ks
Ranch Hand

Joined: Mar 15, 2001
Posts: 122
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

Joined: Sep 29, 2000
Posts: 8521
Are you stuttering???
http://www.javaranch.com/ubb/Forum2/HTML/001179.html


"JavaRanch, where the deer and the Certified play" - David O'Meara
Meghna ks
Ranch Hand

Joined: Mar 15, 2001
Posts: 122
Hi Cindy
Thanks for the reply, but setting the Panel's layout to FlowLayout is aligning all the components horizontally. Basically, the look need is Labels on the Left side and TextFields on the right side of the panel. GridLayout was working perfectly until the Calendar came into existence. So,
Please let me know if you come up with some idea.
Thanks in advance
Meghna
eric moon
Ranch Hand

Joined: Nov 26, 2000
Posts: 133
I think you will have to use a gridBag layout to get the results you need. Check out Professional Java Programming (WROX) for a great discussion of the gridBag. In your case, if you just have 2 columns of data, you will want to set your constraints' gridwidth setting to 1 for the right column and constraints.gridwidth to REMAINDER before adding each left column object:
panel.setLayout(new GridBagLayout());
GridbagConstraints bag = new GridBagConstraints();
bag.gridwidth = 1;
panel.add(component1, bag);
bag.gridwidth = GridBagConstraints.REMAINDER;
panel.add(component2, bag);
etc, etc.
HTH

<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>"Those who cast the votes decide nothing. Those who count the<BR>votes decide<BR>everything." <BR> -Joseph Stalin<HR></BLOCKQUOTE>
Meghna ks
Ranch Hand

Joined: Mar 15, 2001
Posts: 122
Thanks Eric , I'll give it a try and get back to you if I come up with anything.
Thanks
Meghna
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: ScrollPane is always a problem !!!
 
Similar Threads
Positioning slider relative to word in JtextPane.
This goes to Noah & Cindy regarding the scrollbar problem
Having a little problem bringing up a scrollbar
Scrollbar not appearing
Getting the X, Y coordinate values in a JChart