1

JFileChooser dialog , messed up after a secondary JFrame opens. I post you the photos.

Here is the JFileChooser , opens after Open File button

enter image description here

seems perfect right??Now I press Options button

    private void openFileBtn2ActionPerformed(java.awt.event.ActionEvent evt) {                                             

Params ax=new Params();

ax.createGUI();

ax.setPreferredSize(new Dimension(560,450));
ax.setVisible(true);
ax.pack();
ax.setExtendedState(java.awt.Frame.NORMAL);
    } 

JFrame , I mean params class instance opens perfectly.This is supposed to return some values to the main window.However in order to debug this I have removed any references. Now I open JFileChooser again and I take back this mess. enter image description here

It's weird right??Sorry for not posting the code , its too big.I choose to let you ask the code you need.I hope this is more convenient to you.

mKorbel
  • 109,525
  • 20
  • 134
  • 319

1 Answers1

0

I used different look and feel in the second window. I change it and seems to work fine. That was after immibis help.Thank you a lot immibis.

Now I use

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(Reader.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Reader.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Reader.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Reader.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }

in both my main and the second window I open. FIXED !!

  • 1
    You should set the look and feel once and not modify it again while the program is running – MadProgrammer Jan 20 '16 at 11:15
  • I am completely noob.When I make different windows(example frames) I use try{look and feel} in every window (or instance) I open.Is this a mistake? – Tsakiroglou Fotis Jan 20 '16 at 12:19
  • *"When I make different windows(example frames)"* See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) *"I use try{look and feel} in every window (or instance) I open.Is this a mistake?"* Definitely. Set the PLAF in the main before adding creating components. All components thereafter will use that PLAF - so will appear consistent. – Andrew Thompson Jan 20 '16 at 15:30
  • 1
    Then don't call that classes main method – MadProgrammer Jan 20 '16 at 19:08