Resizing Frame
hi,
i am developing a chatting application..
i want to do three things in the Frame Resizing. but i don't know how to do..? any one pls help me..
1. i tried to restrict the user cann't resize the frame less than (300,600) by setSize(). it works. but the user can resize upto 0,0 .. when the user leave the mouse button for resize, then it comes to the preferedsize. i want to restrict the user cannot resize less than 300,600. How to do..?
2. when the user resize the frame size, after leave the mouse button for resize, it draws the frame based up on frame size.. i need to draw the components at the same time when i resize the frame. how to do?
3. when the frame is in resized mode, i want to show the dots (like triangle) in the right-bottom corner of the status bar to indicate the user can maximize or resize the frame. how to do..?
for example, i pasted a sample code which similar to my application.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
publicclass TestFrameextends JFrame
{
public TestFrame()
{
try
{
Toolkit toolkit = Toolkit.getDefaultToolkit();
int x = (toolkit.getScreenSize().width - getWidth()) / 2;
int y = (toolkit.getScreenSize().height - getHeight()) / 2;
Dimension dimension =new Dimension(300,600);
setTitle("TestFrame");
setPreferredSize(dimension);
setMinimumSize(dimension);
setMaximumSize(dimension);
setSize(dimension);
setLocation(x+150,y-350);
setVisible(true);
setDefaultCloseOperation(this.EXIT_ON_CLOSE);
// Event Handling
this.addComponentListener(new ComponentAdapter()
{
publicvoid componentResized(ComponentEvent e)
{
JFrame tmp = (JFrame)e.getSource();
if (tmp.getWidth()<300)
{
tmp.setSize(300, getHeight());
validate();
}
else
if(tmp.getHeight()<600)
{
tmp.setSize(getWidth(), 600);
validate();
}
elseif (tmp.getWidth()<300 && tmp.getHeight()<600)
{
tmp.setSize(300,650);
validate();
}
}
});
init();
pack();
validate();
}
catch(Exception e)
{
e.printStackTrace();
}
}
publicvoid init()
{
JButton b1 =new JButton("Button 1");
Container contentPane = this.getContentPane();
contentPane.add(b1, BorderLayout.SOUTH);
setBackground(Color.WHITE);
}
publicstaticvoid main(String[] args)
{
new TestFrame();
}
}
pls help to solve the problems..
regards,
Gokulakrishnan

