I was thinking about having a readme show up whenever my game was reset using the "System.out.println" method, but the system console does not clear when I reset. Is there a method I can call to clear the system console?
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.GridBagLayout;
import javax.swing.JTextPane;
import java.awt.GridBagConstraints;
public class InformationPopUp extends JDialog {
private static final long serialVersionUID = 1L;
private final JPanel contentPanel = new JPanel();
public InformationPopUp() {
setBounds(100, 100, 450, 300);//here you can change the position and size of the dialog;
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
GridBagLayout gbl_contentPanel = new GridBagLayout();
gbl_contentPanel.columnWidths = new int[]{0, 0};
gbl_contentPanel.rowHeights = new int[]{0, 0};
gbl_contentPanel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
gbl_contentPanel.rowWeights = new double[]{1.0, Double.MIN_VALUE};
contentPanel.setLayout(gbl_contentPanel);
{
JTextPane textPane = new JTextPane();//That's your JTextPane where you can add the text (also a JLabel would work);
GridBagConstraints gbc_textPane = new GridBagConstraints();
gbc_textPane.fill = GridBagConstraints.BOTH;
gbc_textPane.gridx = 0;
gbc_textPane.gridy = 0;
textPane.setText("Add your text here");//This text is printed in the JTextPane;
contentPanel.add(textPane, gbc_textPane);
}
{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
JButton okButton = new JButton("OK");//The OK button;
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
dispose();//make the dialog close when you click the OK button;
}
});
okButton.setActionCommand("OK");
buttonPane.add(okButton);
getRootPane().setDefaultButton(okButton);
}
}
}
}//in your world constructor; new InformationPopUp().setVisible(true);
EventQueue.invokeLater(new Runnable() {
public void run() {
new InformationPopUp().setVisible(true);
}
});