how do i make Jbuttons appear in a panel?

Viewed 17

So i am trying to make my jbutton BUTTON appear in the north panel but when i run my app i can not see the jbutton BUTTON. Why does it do that? I am using intellij. Any help would be appreciated. Also i am sorry for my messy code but here it is. So this part does not matter i already gave the details but it says there is to much code for the text so i am just try to get it.

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.company;

import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;

class Fantasyrpglifesim implements JButton {
    Fantasyrpglifesim() {
    }

    public static void main(String[] args) {
        MouseInputAdapter();
        //Frame//
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        frame.setSize(1500, 1500);
        frame.getContentPane();
        frame.setVisible(true);
        JPanel mainPanel = new JPanel(new BorderLayout());
        JPanel northPanel = new JPanel();
        mainPanel.add(northPanel, BorderLayout.NORTH);
        mainPanel.setVisible(true);
        northPanel.setVisible(true);
        //frame.setLayout(new FlowLayout());//

        //Buttons//
        frame.add(BUTTON);
        BUTTON.setText("Age up");
        northPanel.add(BUTTON);
        //frame.add(BUTTON1);
        //BUTTON1.setText("Test");
        //frame.add(BUTTON2);
        //BUTTON2.setText("Test1");
        //frame.add(BUTTON2);
        //BUTTON2.setText("Test2");
        //frame.add(BUTTON3);
        //BUTTON3.setText("Test3");
        //frame.add(BUTTON4);
        //BUTTON4.setText("Test4");
        //frame.add(BUTTON5);
        //BUTTON5.setText("Test5");
        //frame.add(BUTTON6);
        //BUTTON6.setText("Test6");
        //frame.add(BUTTON7);
        //BUTTON7.setText("Test7");
        //frame.add(BUTTON8);
        //BUTTON8.setText("Test8");
        //frame.add(BUTTON9);
        //BUTTON9.setText("Test9");
        //frame.add(BUTTON10);
        //BUTTON10.setText("Test10");
        //frame.add(BUTTON11);
       //BUTTON11.setText("Test11");
        //frame.add(BUTTON12);
        //BUTTON12.setText("Test12");
        //frame.add(BUTTON13);
        //BUTTON13.setText("Test13");


        //panels//
        //mainPanel.add(northPanel, BorderLayout.NORTH);//
    }


    private static void MouseInputAdapter() {
    }
}```

0 Answers
Related