+ 1

Why this doesn't work?

package prueba2.pkg1; import javax.swing.*; /** * * I am trying to put a botton on a windows but the button is taking all the windows and not only a little space on it */ public class Prueba21 { private int X; private int Y; public class Pestañas extends JFrame{ public Pestañas(){ super("new windows"); setSize(1920,1080); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } public class Botones extends JButton { public Botones(int X,int Y){ setLayout(null); setBounds(X,Y,100,30); setVisible(true); } } /** * {} */ public static void main(String[] args) { Prueba21 pr = new Prueba21(); Pestañas W1 = pr.new Pestañas(); Botones B1 = pr.new Botones(300,250); W1.setVisible(true); W1.add(B1); } } \\edit: i am using NetBeans

4th Apr 2020, 1:53 AM
jared mijail
jared mijail - avatar
2 Réponses
+ 2
add setLayout(null) to Pestañas
4th Apr 2020, 2:16 AM
Bryar Ahmed
Bryar Ahmed - avatar
+ 2
Gui is not supported in sololearn
4th Apr 2020, 1:57 AM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar