E
E
Evgeny Petryaev2020-07-17 14:15:41
Java
Evgeny Petryaev, 2020-07-17 14:15:41

The button does not want to take place by code?

JFrame frame = new JFrame();
            frame.setLocation(0, 0);
            frame.setSize(300,300);
            JButton button = new JButton("close");
            button.setSize(100,50);
            //Dimension dim = new Dimension();
            //dim.width = 100;
            //dim.height = 50;
            //button.setMaximumSize(dim);
            button.setBounds(100, 150, 100, 50);
            button.addActionListener(new ActionListener(){
                    @Override
                    public void actionPerformed(ActionEvent e)
                    {
                        frame.dispose();
                    }
                    });
            JPanel panel = new JPanel();
            panel.setSize(frame.getSize());
            panel.add(button);
            //button.setLocation(100, 250);
            frame.add(panel);

5f1188571e39c551941880.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Petryaev, 2020-07-17
@Gremlin92

Decided by adding panel.setLayout(null);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question