This is what I need to get as the result
There is a game area wich schould be size (800,600) on the left side. On the rest of the window in the right should be Menu/Score Area.
I've got two labels (scoreLabel;pointsLabel;), that i want to put at the top of the menu area, as in the image. in my version i am using gridlayout, but it is not working the way i want :)
import javax.swing.*;
import java.awt.*;
public class PongFrame extends JFrame {
private JLabel scoreLabel;
private JLabel pointsLabel;
public PongFrame () {
this.setTitle("Game");
this.setSize(1100,600);
this.scoreLabel = new JLabel("score");
this.pointsLabel = new JLabel("");
JPanel labelPanel = new JPanel();
labelPanel.setLayout(new GridLayout(1,2));
labelPanel.add(scoreLabel);
labelPanel.add(pointsLabel);
JPanel gameArea = new JPanel();
gameArea.setBackground(Color.orange);
gameArea.setSize(800,600);
Container con = this.getContentPane();
con.setLayout(new GridLayout(1,2));
con.add(gameArea);
con.add(labelPanel);
this.setVisible(true);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public void setPoints (String labeltext){
this.pointsLabel.setText(labeltext);
}
public static void main (String [] args){
PongFrame window = new PongFrame();
window.pointsLabel.setText("0");
}
}