Netbeans GUI Designer & Fixed-Size Application Panels

I had a problem creating a common fixed-size panel for a touch-screen GUI application that should cover the entire screen. In a nutshell, the touch screen has a size of 800 x 600 pixels, so I want the main GUI panel to be that size.

When I start a new GUI project in NetBeans, I set the property of the main panel for min / max / preferred size to 800 x 600, and the panel in the size of the view changes in the "design". However, when I launch the application, it changes to its original size by default.

Adding this code after initComponents () does not help:

this.mainPanel.setSize(new Dimension(800,600));
this.mainPanel.setMaximumSize(new Dimension(800,600));
this.mainPanel.setMinimumSize(new Dimension(800,600));
this.mainPanel.repaint();

I looked at all the resources in the files and cannot seem to find the value that replaces these (which seems somewhat impossible anyway, given that I install them after initComponents () does its job). I use the FreeDesign layout because I need full control over where I put things.

I suspect that the layout manager is resizing based on how many widgets I have on the screen, because the different prototyped screens have different sizes.

Help is appreciated!

+3
source share
3 answers

Have you tried java full screen mode ?

+1
source

, , , , .

protected void growBig()
  {
    int screenWidth = java.awt.Toolkit.getDefaultToolkit().getScreenSize().width;
    int screenHeight = java.awt.Toolkit.getDefaultToolkit().getScreenSize().height;
    Rectangle rectangle = getFrame().getBounds();
    rectangle.setSize(screenWidth, screenHeight);
    getFrame().setBounds(0, 0, screenWidth, screenHeight);
    getFrame().setSize(screenWidth, screenHeight);
    getFrame().doLayout();
    getFrame().validate();
    updateUI();
  }
0

, . Netbeans, , JFrame/JWindow. , 800x600.

, , , < 800600. min/max .

0

Source: https://habr.com/ru/post/1698901/


All Articles