Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Everything moves on resizing window!!!!!

Status
Not open for further replies.

scienzia

Programmer
Feb 21, 2002
160
IT
I need to do a window like this, but when I resize the window everything changes place.
I usually program in Visual C++, and I'm not to good in programming windows with the code.....

________________________________________________________
| S|
| _______________ _______________ C|
| | | | | R|
| | | | | O|
| | | ________________ | | L|
| | | | textbox | | | L|
| | JScrollPane | ________________ |JScrollPane | |
| | | | | |
| | | __________ | | |
| | | | button | | | |
| _______________ __________ _______________ |
| |
| |
________________________________________________________


Here is my code:


gbl=new GridBagLayout();
middlePane=new JPanel(gbl);

GridBagConstraints c= new GridBagConstraints();

c.gridwidth=GridBagConstraints.REMAINDER;

c.ipady=10;
c.ipadx=40;
textBox=new JTextField(10);
gbl.setConstraints(textBox,c);
middlePane.add(textBox);

b=new JButton("AUG");

c.ipady=20;
c.ipadx=40;
gbl.setConstraints(b,c);
middlePane.add(b);

middlePane.setMinimumSize(new Dimension(50, 350));
middlePane.setPreferredSize(new Dimension(50, 350));



GridBagLayout gbl2=new GridBagLayout();
contentPanImages=new JPanel(gbl2);

GridBagConstraints c2= new GridBagConstraints();
c2.ipady=400;
c2.ipadx=250;


scrollPaneL= new JScrollPane(oldImage);

gbl2.setConstraints(scrollPaneL,c2);
contentPanImages.add(scrollPaneL);

//c2.ipady=400;
c2.ipadx=50;

gbl.setConstraints(middlePane,c2);
contentPanImages.add(middlePane);

c2.ipady=400;
c2.ipadx=250;
scrollPaneR= new JScrollPane(newImage);

gbl.setConstraints(scrollPaneR,c2);
contentPanImages.add(scrollPaneR);

contentPanImages.setMinimumSize(new Dimension(550, 450));
contentPanImages.setPreferredSize(new Dimension(550, 450));

scrollPaneBig= new JScrollPane(contentPanImages);


getContentPane().setLayout(new BorderLayout());
getContentPane().add(BorderLayout.NORTH,toolBar);
getContentPane().add(BorderLayout.CENTER,scrollPaneBig);
}
 
Sorry, the image was not so good..

B=button
S= scrollpane
T=TEXTBOX
######################
#SSSSS#########SSSSSS#
#SSSSS###TTTT##SSSSSS#
#SSSSS#########SSSSSS#
#SSSSS###BBBB##SSSSSS#
######################

This all should be in a scrollpane
 
I would suggest that you set the layout to null

Container contentPane = getContentPane();
contentPane.setLayout(null);

then you specify the coordinates where you need to place your components :

comp.setBounds(x,y,width,height)
contentPane.add(comp);

now if you resize your window it will not move the components
 
Thankyou very much, I was getting crazy....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top