I'm making a series of simple ball games, then probably progressing it further. I'm making these games to extend my knowledge about java and I'm trying to make this JLabel show up, and on the right side of this line seperator I've made here's a picture of it.
Here's the code
import javax.swing.*; import java.awt.*; import java.awt.geom.*;
public class MainMenu {
public JFrame BallFrame = new JFrame();
public JPanel BallPanel = new JPanel();
public static MainMenu instance;
Line2D verticalLine;
public int[] menuSize = {400, 380}; public int getMenuSize(int id) { if(id>=0 && id<=1) { return menuSize[0]; }else{ return menuSize[1]; } };
public static void main(String[] args) {
boolean scrollAble = Boolean.parseBoolean(args[0]);
MainMenu menu = instance = new MainMenu();
menu.startUp();
/*if(scrollAble){
JScrollPane pane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
menu.BallFrame.setContentPane(pane);
} else {
menu.BallFrame.setContentPane(menu.BallPanel);
}*/
}
public int[] RightHandMessageBounds = {5,5}; public int getRightHandMessageBounds(int id){ if(id==1){ return RightHandMessageBounds[0]; }else{ return RightHandMessageBounds[1]; } };
private void startUp() {
JLabel RightHandMessage;
RightHandMessage = new JLabel("<html><col=000000>Welcome to the ball game!</font></html>", JLabel.CENTER);
RightHandMessage.setLocation(getRightHandMessageBounds(1),getRightHandMessageBounds(2));
BallFrame.setLocationRelativeTo(null);
BallFrame.setTitle("The Ball Game V1 - Cam");
BallFrame.setSize(getMenuSize(1),getMenuSize(2));
BallPanel.setLayout(new FlowLayout());
//BallPanel.setBackground(Color.WHITE);
BallPanel.setSize(getMenuSize(1),getMenuSize(2));
BallPanel.add(createVerticalSeparator());
BallPanel.add(RightHandMessage);
BallFrame.setContentPane(BallPanel);
BallFrame.setLocationByPlatform(true);
BallPanel.setVisible(true);
BallFrame.setVisible(true);
}
public static JComponent createVerticalSeparator() {
JSeparator x = new JSeparator(SwingConstants.VERTICAL);
x.setPreferredSize(new Dimension(3,9999*100));
return x;
}