Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot Display JOptionPane When Button Is Pressed
    primarykey
    data
    text
    <p>So I have the following Code:</p> <pre><code>import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextPane; @SuppressWarnings("serial") public class Window extends JPanel implements ActionListener { public static JTextPane text = new JTextPane(); public static BorderLayout layout = new BorderLayout(); public static JButton debug = new JButton("Debug"); public static boolean isDebugPressed = false; public static JFrame frame = new JFrame(); public Window(){ debug.addActionListener(this); this.setLayout(layout); this.add(debug,BorderLayout.NORTH); this.add(text,BorderLayout.CENTER); } public static void main(String[] args){ Window window = new Window(); frame.setLayout(layout); frame.setSize(new Dimension(600,600)); frame.setTitle("QuickScript Compiler"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.setVisible(true); frame.setLocationRelativeTo(null); frame.add(window); debug.setActionCommand("debug"); if (isDebugPressed){ JOptionPane.showMessageDialog(frame, "Output: " + text.getText().toString() , "Debugging", JOptionPane.PLAIN_MESSAGE); } } @Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("debug")){ isDebugPressed = true; System.out.println("true"); } } </code></pre> <p>and when I press the debug button a box should pop up and display whatever I typed inside of the text pane, but there is nothing that shows up. How do I fix this? I have a feeling that I may have missed something very important, but I just can't figure out what it is. Thanks to anybody who can help :D</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload