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?


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 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); } } } } |
1 2 | //in your world constructor; new InformationPopUp().setVisible( true ); |
1 2 3 4 5 | EventQueue.invokeLater( new Runnable() { public void run() { new InformationPopUp().setVisible( true ); } }); |