How to correctly configure the JAVA LookAndFeel?

0

I'm having a problem with the LookAndFeel of a desktop app developed in JDeveloper, the issue is that when running the app from the "Run", the LookAndFeel is "Nimbus", but when I do the deploy it runs with another LookAndFeel .

Any recommendations?

Calaro that never set the LookAndFeel, is the default:

    public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(FrameInicio.class.getName()).log(java.util.logging.Level.SEVERE, null,
                                                                            ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(FrameInicio.class.getName()).log(java.util.logging.Level.SEVERE, null,
                                                                            ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(FrameInicio.class.getName()).log(java.util.logging.Level.SEVERE, null,
                                                                            ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(FrameInicio.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 FrameInicio(0, "system").setVisible(true);
        }
    });
}

But when doing the deploy, the buttons are the default squares.

UPDATE:

I had to add the following code in the constructor:

        try {
        javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
    } catch (UnsupportedLookAndFeelException e) {
    } catch (IllegalAccessException e) {
    } catch (InstantiationException e) {
    } catch (ClassNotFoundException e) {
    }
    
asked by NombreParaMostrar 19.06.2018 в 17:28
source

0 answers