So I have looked through ton of topics about this, but none seem to fix my problem! When I try to use setBounds() or setLocation() on JLabel or JButton it just doesn't work! It seems to place both of them just randomly. Here is my code:
public static void main(String[] args) {
final JFrame frame = new JFrame(TITLE);
final JLabel fpsLabel = new JLabel("FPS: ERROR");
final JLabel fpsDone = new JLabel("FPS done: ERROR");
final JPanel contentPanel = new JPanel();
frame.setSize(WIDTH, HEIGHT);
frame.setContentPane(contentPanel);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fpsLabel.setLocation(WIDTH / 2, HEIGHT / 6);
fpsDone.setLocation(200, HEIGHT / 6);
frame.setJMenuBar(menubar);
frame.setResizable(false);
frame.add(fpsLabel);
frame.add(fpsDone);
frame.setVisible(true);
}
If needed I can add picture.
SSCCE:
public static void main(String[] args) {
final JFrame frame = new JFrame("Example SSCCE");
final JLabel fpsLabel = new JLabel("FPS: ERROR");
final JLabel fpsDone = new JLabel("FPS done: ERROR");
final JPanel contentPanel = new JPanel();
final int HEIGHT = 400 / 16 * 9;
frame.setSize(400, HEIGHT);
frame.setContentPane(contentPanel);
fpsDone.setLocation(200, HEIGHT / 2);
fpsLabel.setLocation(200, HEIGHT / 2 + 50);
contentPanel.add(fpsDone);
contentPanel.add(fpsLabel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
What I would want it to look like (ASCII art?):
__________________________________
| |
| |
| |
| |
| |
| FPS: ERROR |
| FPS done: ERROR |
| |
| |
| |
| |
| |
__________________________________