Wygląd aplikacji

0

Witam,

chciałbym się dowiedzieć jak ustawić wygląd aplikacji na windowsowy ?

0
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {}

u mnie to robi windows L&F

A to wylistuje Ci wszytkie dostępne w danej chwili ( w systemie L&F)

 UIManager.getInstalledLookAndFeels()
0
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch(Exception e) {
          JOptionPane.showMessageDialog(this, e.toString(), "Błąd", JOptionPane.ERROR_MESSAGE);
            }
              SwingUtilities.updateComponentTreeUI(this);
        }

 

P.S. Po zmianie wyglądu na systemowy w Windowsie mogą wystąpić problemy z dodaniem filtrów plików dla okienek typu "Otwórz plik" itp....

W razie problemów spróbuj coś takiego :

import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.*;
...
public class PlikiTekstoweFiltr extends FileFilter {

    public boolean accept(File f) {
        if (f.isDirectory()) {
            return true;
        }

        String extension = getExtension(f);
        if (extension != null) {
            if (extension.equals("txt")) {
                    return true;
            } else {
                return false;
            }
        }

        return false;
    }
        public static String getExtension(File f) {
        String ext = null;
        String s = f.getName();
        int i = s.lastIndexOf('.');

        if (i > 0 &&  i < s.length() - 1) {
            ext = s.substring(i+1).toLowerCase();
        }
        return ext;
    }

    //Opis filtra
    public String getDescription() {
        return "Pliki tekstowe (*.txt)";
}
    
}

i gdzieś w kodzie :

 
              jFileChooser1.addChoosableFileFilter(new PlikiTekstoweFiltr());
              jFileChooser1.setAcceptAllFileFilterUsed(false);

1 użytkowników online, w tym zalogowanych: 0, gości: 1