Well in the middle of designing my text based game I decided to take a route of making a GUI in windows builder, note that I just started learning GUI's so go easy on me.
Anyways the issue is on the start up of the program when the window that appears which is suppose to be the GUI is actually blank and doesn't allow me to exit so I have to terminate the program in eclipse.
Also note when executing it in the main startup, its executed as mainGameGUI, not under a constructor.
Here is the code.
private static JFrame frame;
private static JTextField txtBeginByTyping;
public static void mainGameGUI() {
frame = new JFrame();
frame.setBounds(100, 100, 600, 700);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
frame.setVisible(true);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
final JTextArea textArea = new JTextArea();
textArea.setBounds(10, 415, 371, 205);
textArea.setRows(8);
textArea.setEditable(false);
frame.getContentPane().add(textArea);
JProgressBar progressBar = new JProgressBar();
progressBar.setBackground(Color.RED);
progressBar.setToolTipText("");
progressBar.setForeground(Color.RED);
progressBar.setValue(Player.currentHp);
progressBar.setMaximum(Player.maxHp);
progressBar.setBounds(401, 517, 173, 40);
frame.getContentPane().add(progressBar);
JLabel lblYourHealth = new JLabel("Health");
lblYourHealth.setHorizontalAlignment(SwingConstants.CENTER);
lblYourHealth.setFont(new Font("Trajan Pro", Font.PLAIN, 16));
lblYourHealth.setBounds(401, 470, 173, 36);
frame.getContentPane().add(lblYourHealth);
JLabel lblDestructivePower = new JLabel("Destruction: " + Player.totalDamage);
lblDestructivePower.setHorizontalAlignment(SwingConstants.LEFT);
lblDestructivePower.setFont(new Font("Trajan Pro", Font.PLAIN, 16));
lblDestructivePower.setBounds(401, 568, 173, 40);
frame.getContentPane().add(lblDestructivePower);
JLabel lblNewLabel = new JLabel("Gold Coins: " + Player.currency);
lblNewLabel.setHorizontalAlignment(SwingConstants.LEFT);
lblNewLabel.setFont(new Font("Trajan Pro", Font.PLAIN, 16));
lblNewLabel.setBounds(401, 619, 173, 32);
frame.getContentPane().add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("Realm of the Gods");
lblNewLabel_1.setBounds(10, 11, 564, 60);
frame.getContentPane().add(lblNewLabel_1);
JLabel lblNewLabel_2 = new JLabel("Images go here");
lblNewLabel_2.setBounds(10, 82, 564, 322);
frame.getContentPane().add(lblNewLabel_2);
txtBeginByTyping = new JTextField();
txtBeginByTyping.setText("");
txtBeginByTyping.setBounds(10, 631, 381, 20);
frame.getContentPane().add(txtBeginByTyping);
txtBeginByTyping.setColumns(10);
txtBeginByTyping.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
inputReader.input = txtBeginByTyping.getText();
textArea.append(inputReader.input + "\n");
txtBeginByTyping.setText("");
}
});
JScrollPane scrollPane = new JScrollPane();
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBounds(380, 415, 11, 205);
frame.getContentPane().add(scrollPane);
JLabel lblNewLabel_3 = new JLabel("Town of Neo");
lblNewLabel_3.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_3.setFont(new Font("Trajan Pro", Font.PLAIN, 16));
lblNewLabel_3.setBounds(401, 416, 173, 40);
frame.getContentPane().add(lblNewLabel_3);
}