I can\'t get my JFrame from main class to display JPanel from another class. Everything compiles without errors.
JFrameTest.java:
pa
The problem comes from the JPanelOne
class. It inherits JPanel
but in the constructor, you create a new JPanel
and then you add a button to it. If you do this instead:
public class JPanelOne extends JPanel {
public JPanelOne() {
JButton button = new JButton("test");
add(button);
}
}
it should work as you expect it.