In one of my application I want to add some JButtons
in a limited space so I created a JPanel
of the required size, but when I added the JButtons
on that JPanel
, they are not visible in the given space.
Here is the code:
import javax.swing.*;
import java.awt.event.*;
class MyTest
{
public static void main(String... args) {
JFrame jf=new JFrame();
JPanel jp=new JPanel();
jp.setSize(10,10);
jp.add(new JButton("1"));
jp.add(new JButton("2"));
jp.add(new JButton("3"));
jf.add(jp);
jf.setSize(500,500);
jf.setVisible(true);
}
}