I am still learning java in college but I just would like to know the way or ways to put the JComponent
's in specific location and specify their size.
I have seen the methods setLocation()
and that sort of methods but I just really wanna know how to put a Component
without using those layout managers(flow, grid, border?).
Here is the code I would like to apply that knowledge to: they are two overloaded methods that display the same window.
public void addWelcome()
{
setWindow();
MaxDimension = new Dimension(WelcomeLabelDimensionWidth,WelcomeLabelDimensionHeight);
getWindow().setMaximumSize(MaxDimension);
MinDimension = new Dimension(WelcomeLabelDimensionWidth,WelcomeLabelDimensionHeight);
getWindow().setMinimumSize(MinDimension);
getWindow().setTitle("Bills");
getWindow().setSize(WindowWidth,WindowHeight);
getWindow().setDefaultCloseOperation(EXIT_ON_CLOSE);
getWindow().setLayout(new GridLayout(5,1,2,0));
getWindow().add(getWelcomeLabel());
getWindow().add(getGreetLabel());
getWindow().add(getDescriptionLabel());
getWindow().add(getInstructionLabel());
getWindow().add(getStartButton());
getWindow().pack();
getWindow().setVisible(true);
}
public void addWelcome(final int Width, final int Height)
{
setWindow();
MaxDimension = new Dimension(Width,Height);
getWindow().setMaximumSize(MaxDimension);
MinDimension = new Dimension(Width,Height);
getWindow().setMinimumSize(MinDimension);
getWindow().setTitle("Bills");
getWindow().setSize(WindowWidth,WindowHeight);
getWindow().setDefaultCloseOperation(EXIT_ON_CLOSE);
getWindow().setLayout(new GridLayout(5,1));
getWindow().add(getWelcomeLabel());
getWindow().add(getGreetLabel());
getWindow().add(getDescriptionLabel());
getWindow().add(getInstructionLabel());
getWindow().add(getStartButton());
getWindow().setVisible(true);
}
Apologize if code/question are not clear enough.
Thanks in advance.