How to resize the height of JWindow from JButton actions (i tried setSize and repaint but it does not work) ?
public class Gui extends JWindow implements KeyListener
{
public static Gui mystatic;
private static JPanel panelBgImg;
private final Dimension screen;
public static int w = 0;
public static int h = 0;
public void paintComponent(Graphics g)
{
}
public Dimension getPreferredSize()
{
return new Dimension(100, h);
}
public Gui()
{
....
/* Button 1 */
JButton jb2 = new JButton("")
{
public Dimension getPreferredSize()
{
return new Dimension(50,50);
}
};
jb2.setOpaque(false);
jb2.setContentAreaFilled(false);
jb2.setBorderPainted(false);
jb2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
h = 100;
/* HERE i am trying to resize the JWindow itself but not working
return new Dimension(100, h); */
mystatic.setSize(screen.width, 100);
mystatic.repaint();
}
});
...
}
for example
please don’t use
Thread.sleep(int)durring EDT, as demonstrated in this code example, there is used for closing current JVM instance, otherwise this instance never gone from PC’s RAM