Integer return methods make components invisible in JPanel

I have a very strange problem. I am writing an interface for a hand-drawn program and creating a class that extends JLabel. I added basic components and necessary variables, as shown below:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import shapes.*;

public class denemePanel extends JPanel {

    int radius;
    int height;
    int width;
    String color;
    JButton drawButRect;
    JButton drawButCirc;
    JButton drawButRand;
    JButton paintBut;
    JLabel heightL;
    JLabel widthL;
    JLabel radiusL;
    JLabel colorL;
    JTextField colorF;
    JTextField heightF;
    JTextField widthF;
    JTextField radiusF;
    ShapeContainer shapes;
    boolean drawRect;
    boolean drawCirc;
    boolean drawRand;
    boolean isColor;
    ButtonListener buttonListener;

    public denemePanel( ShapeContainer shapes) {

        height = -1;
        radius = -1;
        width = -1;
        color = "";
        drawRect = false;
        drawCirc = false;
        drawRand = false;
        isColor = false;
        buttonListener = new ButtonListener();
        setLayout( new GridLayout( 0,7, 5, 5));
        setPreferredSize( new Dimension( 700, 150));
        shapes = this.shapes;
        drawButRect = new JButton( "Draw!");
        drawButCirc = new JButton( "Draw!");
        drawButRand = new JButton( "Draw any!");
        paintBut = new JButton( "Paint!");
        drawButRect.addActionListener( buttonListener);
        drawButCirc.addActionListener( buttonListener);
        drawButRand.addActionListener( buttonListener);
        paintBut.addActionListener( buttonListener);
        heightL = new JLabel( "Height:");
        widthL = new JLabel( "Width:");
        radiusL = new JLabel( "Radius:");
        colorL = new JLabel( "Color:");
        heightF = new JTextField( "0");
        colorF = new JTextField( "yellow/red");
        widthF = new JTextField( "0");
        radiusF = new JTextField( "0");
        add( heightL);
        add( heightF);
        add( radiusL);
        add( radiusF);
        add( new JLabel( ""));
        add( colorL);
        add( colorF);
        add( widthL);
        add( widthF);
        add( new JLabel( ""));
        add( new JLabel( ""));
        add( new JLabel( ""));
        add( new JLabel( ""));
        add( new JLabel( ""));
        add( new JLabel( ""));
        add( drawButRect);
        add( new JLabel( ""));
        add( drawButCirc);
        add( drawButRand);
        add( new JLabel( ""));
        add( paintBut);
        setVisible( true);
    }

    //Methods
    public int getRadius() {
        return radius;
    }
    public int getHeight() {
        return height;
    }
    public int getWidth() {
        return width;
    }
    public String getColor() {
        return color;
    }
    //Methods end

    //-------------------------------------ACTION LISTENER-----------------------------------------------
    public class ButtonListener implements ActionListener {

        public void actionPerformed( ActionEvent e) {

            if( e.getSource() == drawButRect) {
                height = Integer.parseInt( heightF.getText());
                width = Integer.parseInt( widthF.getText());
                if( height > 0 && width > 0) {
                drawRect = true;
                drawCirc = false;
                drawRand = false;
                isColor = false;
                }
                else {
                    JOptionPane.showMessageDialog(null, "Not a valid input!");
                    drawRect = false;
                    drawCirc = false;
                    drawRand = false;
                    isColor = false;
                }
            }

            else if( e.getSource() == drawButCirc) {
                radius = Integer.parseInt( radiusF.getText());
                if( radius > 0) {
                    drawRect = false;
                    drawCirc = true;
                    drawRand = false;
                    isColor = false;
                }
                else {
                    JOptionPane.showMessageDialog(null, "Not a valid input!");
                    drawRect = false;
                    drawCirc = false;
                    drawRand = false;
                    isColor = false;  
                }
            }

            else if( e.getSource() == drawButRand) {
                drawRect = false;
                drawCirc = false;
                drawRand = true;
                isColor = false;
            }

            else if( e.getSource() == paintBut) {
                color = colorF.getText().toLowerCase();
                if( color.equals( "red") || color.equals( "yellow")) {
                    drawRect = false;
                    drawCirc = false;
                    drawRand = false;
                    isColor = true;
                }
                else {
                    JOptionPane.showMessageDialog(null, "Not valid color -just red or yellow!");
                    drawRect = false;
                    drawCirc = false;
                    drawRand = false;
                    isColor = false;
                }
            }
        }
    }
    //-----------------------------------------------------------------------------------------------------------
}

Before adding the "methods" part, my code worked as follows:

After adding methods (just methods), it became so (no components are visible, but that's all, they really work! So, if I press the button that I know, it is, it works as intended to):

, , String (Uncommenting , uncommented .). , .

//Methods
public int getRadius() {
    return radius;
}
public int getHeight() {
    return height;
}
public int getWidth() {
    return width;
}
public String getColor() {
    return color;
}
//Methods end

, setVisible() Panel, . !

+4
2

getHeight() getWidth(), JPanel, .

+7

"" , "" - (JPanel). , , , ; , , , .

JPanel, , .

+2

All Articles