Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying a scroll bar only when necessary

Tags:

java

scroll

swing

I'd like to do something like the following:

    public class MyCustomDialog extends JDialog 
    {

       public MyCustomDialog()
       {
          if (getClientVertScreenSize() < 800)
          {
            // Set the vertical size as 600, and give them a scroll pane to navigate to the bottom of the gui.
          }
          else
          {
             setSize(600, 800); // No need to add a scroll pane.
          }
       }

    }

The trouble is I don't know how to check the clients' screen size, so I don't know how to write the method my constructor relies on.

like image 353
Sal Avatar asked Feb 26 '26 23:02

Sal


1 Answers

See Toolkit.getDefaultToolkit().getScreenSize()

like image 97
ControlAltDel Avatar answered Mar 01 '26 12:03

ControlAltDel