There is a class that adds Button and TextField to the panel. But, when in ColorAction I try to register actions when I press a button, the compiler does not see the panel, Button, Textfield. Where is the mistake?
class BPanel extends JPanel { public BPanel() { JButton Button = new JButton("Button_"); JTextField Text = new JTextField(15); add(Button); add(Text); ActionListener actionListener = new ColorAction(); Button.addActionListener(actionListener); } protected class ColorAction implements ActionListener { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(panel, "ppppp"); //ошибка, не видит panel } } } class ButtonFrame extends JFrame { public ButtonFrame() { setTitle("Test"); setSize(500, 200); BPanel panel = new BPanel(); Container contentPane = getContentPane(); contentPane.add(panel) ; } }
panel
at all? - falstaf