1

[SOLVED]: I have Lenovo Z500 notebook, which use it's own video driver for Intel HD 4000. I use this driver because of it interacts with hotkeys on my laptop keyboard (F11, F12 for screen brightness). I tested compiled JAR file on my second Dell laptop and everything works fine! If you have any problems with rendering Swing elements on your Lenovo laptop with Lenovo pre-installed drivers, you have to install native Intel driver.

===

I made a Swing application using Windows L&F, but after Run (compile) i see wrong rendering elements. BUT! when i use preview, everything looks OK. Here's some screens of bugs (i think):

Left side: Preview Right side: Run Mode

Preview Mode Run mode

As you can see on the right picture, we have a thick line (like duplicate) on a left side of each element (including jTextField, jComboBox, jSpinner and others) except Buttons in Run Mode. Does anybody know what's a problem? Somebody said in here that it's problems with video card driver, but what exactly should i do to fix this problem?

  • System: Winodows 8.1
  • NetBeans: 8.0
  • Java SDK: 1.8.0_11

Thank's ahead for any answers!

Full source code goes below:

public static void main(String args[]) {

    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Windows".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(mainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(mainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(mainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(mainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new mainWindow().setVisible(true);
        }
    });
}

GUI elements generated by NetBeans:

private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jComboBox1 = new javax.swing.JComboBox();
        jTextField1 = new javax.swing.JTextField();
        jSpinner1 = new javax.swing.JSpinner();
        jProgressBar1 = new javax.swing.JProgressBar();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Button");

        jButton1.setText("jButton1");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jProgressBar1.setMinimum(1);
        jProgressBar1.setValue(25);
        jProgressBar1.setStringPainted(true);

        jLabel2.setText("ComboBox");

        jLabel3.setText("TextField");

        jLabel4.setText("Spinner");

        jLabel5.setText("ProgressBar");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jTextField1)
                    .addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton1)
                            .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jButton1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jProgressBar1, jSpinner1});

        pack();
    }
7
  • 2
    Please edit your question to include a minimal, complete example that exhibits the problem you describe. Your use of a GUI editor at this stage in development may be a problem; minimal would exclude any generated code, yet complete enough for someone with your setup to run. Commented Nov 29, 2014 at 12:28
  • for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Windows".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; }} So Windows PLAF for Windows and bugger the rest? And by 'bugger the rest' I mean leave OS X and Linux/Unix to see ..Metal (shudder). Why not instead UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());? The resulting PLAF would be Windows 7 for Windows, Aqua for OS X and GTK or CDE/Motif for Linux & Unix based systems. Commented Nov 29, 2014 at 12:58
  • @AndrewThompson, i tried you way but everything looks the same ( Here's code example: public static void main(String args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); ... Commented Nov 29, 2014 at 13:06
  • "but everything looks the same" ..do you use Windows? (checks screenshots, of course you do). The point is it will look different (to the default Metal PLAF) on OS X and Linux/Unix! Commented Nov 29, 2014 at 13:08
  • @AndrewThompson, of course! You can see it in my first post: System: Winodows 8.1 Commented Nov 29, 2014 at 13:09

1 Answer 1

2

Using Windows 8.1 Pro, with JRE 1.8.0_25, i see no problem in the rendered gui, here is my screenshot:

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

Hm.. really strange ) I have Windows 8.1 SL, but the result differs from yours... Can you tell me what video card do you have?
@alexkowalski I have a cheap video card: Mobile Intel(R) 4 Series Express Chipset Family
I found a problem! I have Lenovo Z500 notebook, which use it's own video driver for Intel HD 4000. I use this driver because of it interacts with hotkeys on my laptop keyboard (F5, F6 etc.). I tested this compiled JAR file on my second Dell laptop and everything works fine! Great! Thank you for you testing and helping me, i thought it wasn't my local problem!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.