I working on assignment to create bank management GUI with swing. Right now I'm messing with login. Instead of using JDialog as many may suggest to use I used JFrame.
In case of any error messages on login attempt I wanted to display error above all previously displayed content, however that will end up with message to be displayed next to original content
However if I swap order of GridBagConstrains , to show message at the bottom, the layout is correct :?:
I must be doing something somewhere wrong when I either clear or re-build the frame. Also JFrame should make change in size but frame doesn't seems to get affected by this. There is a flick of larger frame, but it never change the size.
private Dimension dimLF = new Dimension(250, 150);
private Dimension dimLFErr = new Dimension(500, 500);
So the question is what I'm doing wrong?
Here is the section of code that "takes" care of this
public void runLoginFrame()
{
lf.setTitle("BMS - Login");
if(errJP.getComponentCount()!= 0)
{
lf.getContentPane().remove(errJP);
}
if (errMsg)
{
setErrorMsg();
setLoginLayout();
lf.setSize(dimLFErr);
lf.setLayout(gbag);
gbc.gridx = 0;
gbc.gridy = 1; // correct layout change to zero
gbag.setConstraints(loginJP, gbc);
gbc.gridx = 0;
gbc.gridy = 0; // correct layout change to one
gbag.setConstraints(errJP, gbc);
lf.getContentPane().add(errJP);
lf.getContentPane().add(loginJP);
}
else
{
lf.setSize(dimLF);
setLoginLayout();
lf.getContentPane().add(loginJP);
}
lf.setLocation(rp.resultPosition(dimLF));
lf.setResizable(false);
lf.addWindowListener(this);
lf.setVisible(true);
lf.pack();
}
PS: If additional code need it let me know