There is a class MyFrame, which describes the creation of a frame, and in this class the JPanel component is created.
And there is a Example class in which a Button is created, and then I want to add this Button to a JPanel. But an error pops up: the panel cannot be resolved. Where is the mistake?
class MyFrame extends JFrame { public MyFrame() { setSize(300, 400); setTitle("Example"); JPanel panel = new JPanel(); panel.setBackground(Color.green); add(panel); } } class Example { public Example() { JButton Button = new JButton("oooooo"); panel.add(Button); //в этой строке показывает ошибку } }
MyFrameExample class need to know about the local variablepanelin theMyFrameconstructor? - VladD