aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Bean Resizing problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Bean Resizing problem" Watch "Bean Resizing problem" New topic
Author

Bean Resizing problem

Sandhya
Greenhorn

Joined: Feb 28, 2001
Posts: 3
Hi
I've designed a bean inside an applet overriding the ComponentResized event for both the bean and the applet. During run time, when I drag the bean all its components gets resized properly, but when I use the maximise buttons, the bean components(the bean has a JTable, 2 JButtons and a JScrollPane) and the applet components(2 JButtons) don't function properly.
Here is the sample code for both of them. I would really appreciate if anybody could throw some light on this.
void BeanTable_componentResized(java.awt.event.ComponentEvent event)
{
JLabel1.setText("Bean Resized");
int width = this.getWidth();
int height = this.getHeight();
System.out.println("Bean width = " + width + "Bean Height = " + height);
setBeansize(width, height);
System.out.println("Bean width = " + width + "Bean Height = " + height);
}
================================================================
public void setBeansize(int width, int height)
{
int x = this.getX(); int y = this.getY();
int b1x = JButton1.getX(); int b1y = JButton1.getY();
int b1w = JButton1.getWidth(); int b1h = JButton1.getHeight();
int b2x = JButton2.getX(); int b2y = JButton2.getY();
int b2w = JButton2.getWidth(); int b2h = JButton2.getHeight();
int spx= JScrollPane1.getX(); int spy = JScrollPane1.getY();
int spw = JScrollPane1.getWidth(); int sph = JScrollPane1.getHeight();
int t1x = JTable1.getX(); int t1y = JTable1.getY();
int t1w = JTable1.getWidth(); int t1h = JTable1.getHeight();
int l1x = JLabel1.getX(); int l1y = JLabel1.getY();
int l1w = JLabel1.getWidth(); int l1h = JLabel1.getHeight();
int btn_space = b2x - b1x - b1w;
this.setSize(width ,height );
JScrollPane1.setBounds(0, 0, width, height);

if( width < 409 )<br /> {<br /> JButton1.setBounds(b1x, b1y, b1w, b1h);<br /> JButton2.setBounds(b2x, b2y, b2w, b2h);<br /> JLabel1.setBounds(l1x, l1y, l1w, l1h);<br /> <br /> }<br /> else <br /> {<br /> b1x = (width - (b1w + btn_space + b2w))/2;<br /> JButton1.setBounds(b1x, b1y, b1w, b1h );<br /> b2x = b1x + b1w + btn_space;<br /> JButton2.setBounds(b2x, b2y, b2w, b2h);<br /> l1x = b1x;<br /> JLabel1.setBounds(l1x, l1y, l1w, l1h);<br /> <br /> } <br /> }<br /> ================================================================<br /> void JApplet1_componentResized(java.awt.event.ComponentEvent event)<br /> { <br /> int width = this.getWidth();<br /> int height = this.getHeight();<br /> int b1x = JButton1.getX();<br /> int b1y = JButton1.getY();<br /> int b1h = JButton1.getHeight();<br /> int b1w = JButton1.getWidth();<br /> int b2w = JButton2.getWidth();<br /> int b2h = JButton2.getHeight();<br /> int b2x = JButton2.getX();<br /> int b2y = JButton2.getY();<br /> int btn_space = b2x - b1x - b1w;<br /> System.out.println("Applet width and height " + width + " " + height);<br /> <br /> if( width <= 409)<br /> {<br /> JButton1.setBounds(b1x, b1y, b1w, b1h);<br /> JButton2.setBounds(b2x, b2y, b2w, b2h);<br /> System.out.println("Applet Buttons<=409 => " + "b1x " + b1x + "b1y " + b1y);<br /> System.out.println("Applet Buttons<=409 => " + "b2x " + b2x + "b2y " + b2y);<br /> }<br /> else <br /> {<br /> b1x = (width - (b1w + btn_space + b2w))/2;<br /> JButton1.setBounds(b1x, b1y, b1w, b1h );<br /> b2x = b1x + b1w + btn_space;<br /> JButton2.setBounds(b2x, b2y, b2w, b2h);<br /> b_table.BeanTable_componentResized(event);<br /> System.out.println("Applet Buttons>409 => " + "b1x " + b1x + "b1y " + b1y);
System.out.println("Applet Buttons>409 => " + "b2x " + b2x + "b2y " + b2y);
System.out.println(" =============================================");
b_table.setBeansize(width, height);

}

}
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bean Resizing problem