本文整理匯總了Java中javax.swing.UIManager.setLookAndFeel方法的典型用法代碼示例。如果您正苦於以下問題:Java UIManager.setLookAndFeel方法的具體用法?Java UIManager.setLookAndFeel怎麽用?Java UIManager.setLookAndFeel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.UIManager
的用法示例。
在下文中一共展示了UIManager.setLookAndFeel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import javax.swing.UIManager; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
defaultBackgroudColor = (Color) Toolkit.getDefaultToolkit()
.getDesktopProperty("win.mdi.backgroundColor");
String[] lookAndFeel = new String[]{
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel",
"com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"};
for (String laf : lookAndFeel) {
UIManager.setLookAndFeel(laf);
SwingUtilities.invokeAndWait(() -> {
JDesktopPane desktopPane = new JDesktopPane();
Color background = desktopPane.getBackground();
if (!background.equals(defaultBackgroudColor)) {
throw new RuntimeException("Invalid JDesktopPane "
+ "Background Color for WLAF");
}
});
}
}
示例2: setLookAndFeel
import javax.swing.UIManager; //導入方法依賴的package包/類
/**
* Sets the look and feel of the JDialog similar to the main application window.
*/
private void setLookAndFeel() {
String lnfClassName = Application.getGlobalInfo().getAppLookAndFeelClassName();
if (lnfClassName==null) return;
String currLookAndFeelClassName = UIManager.getLookAndFeel().getClass().getName();
if (lnfClassName.equals(currLookAndFeelClassName)==true) return;
try {
UIManager.setLookAndFeel(lnfClassName);
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
System.err.println("Cannot install " + lnfClassName + " on this platform:" + e.getMessage());
}
}
示例3: Installer
import javax.swing.UIManager; //導入方法依賴的package包/類
public Installer(JsonObject json) {
this.versions = json.entrySet();
System.out.println(versions.toString());
String low = "", high = "";
for (Map.Entry<String, JsonElement> entry : versions) {
if (high.isEmpty()) {
high = entry.getKey();
} else {
low = entry.getKey();
}
}
v = (low.isEmpty() ? high : low + "-" + high);
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
this.setTitle(Main.name + " Installer");
this.initGui();
}
示例4: init
import javax.swing.UIManager; //導入方法依賴的package包/類
@Override
public void init() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JMenuBar bar = new JMenuBar();
JMenu menu = new JMenu("Menu");
JCheckBoxMenuItem checkBoxMenuItem
= new JCheckBoxMenuItem("JCheckBoxMenuItem");
checkBoxMenuItem.setSelected(true);
menu.add(checkBoxMenuItem);
bar.add(menu);
setJMenuBar(bar);
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例5: init
import javax.swing.UIManager; //導入方法依賴的package包/類
public void init() {
JFrame.setDefaultLookAndFeelDecorated(true);
try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
} catch (ClassNotFoundException | InstantiationException |
IllegalAccessException | UnsupportedLookAndFeelException ex) {
throw new RuntimeException("Test Failed. MetalLookAndFeel not set "
+ "for frame");
}
frame = new JFrame("JFrame Maximization Test");
frame.pack();
frame.setSize(450, 260);
frame.setVisible(true);
}
示例6: main
import javax.swing.UIManager; //導入方法依賴的package包/類
public static void main(String[] args) {
UIManager.put("swing.boldMetal", Boolean.FALSE);
JDialog.setDefaultLookAndFeelDecorated(true);
JFrame.setDefaultLookAndFeelDecorated(true);
Toolkit.getDefaultToolkit().setDynamicLayout(true);
System.setProperty("sun.awt.noerasebackground", "true");
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
System.out.println(
"Metal Look & Feel not supported on this platform. \n"
+ "Program Terminated");
System.exit(0);
}
JFrame frame = new MetalworksFrame();
frame.setVisible(true);
}
示例7: initLookAndFeel
import javax.swing.UIManager; //導入方法依賴的package包/類
private static void initLookAndFeel() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
util.BrLogger.Logger("ERROR_APP_LOAD_UI", ex.getMessage());
}
}
示例8: main
import javax.swing.UIManager; //導入方法依賴的package包/類
/**
* <p>Called on startup. This has two roles. First, it looks for the Artemis install location and, if it doesn't find it, asks the user where it is. Then, if it knows where Artemis is installed, it launches the main window, which contains the rest of the program logic.</p>
* @see MainWindow
* @param args Command-line arguments. These are currently ignored.
* */
public static void main(String[] args) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //Use system look and feel
MainWindow mw = new MainWindow(); //Create the user interface (so that we can use it as a parent for the file chooser further down) but don't show it yet.
if(PreferenceManager.getInstance().getStringPreference(PreferenceManager.PREF_ARTEMIS_INSTALL).equals("") || !new File(PreferenceManager.getInstance().getStringPreference(PreferenceManager.PREF_ARTEMIS_INSTALL) + "/Artemis.exe").exists()) { //If we haven't already got the Artemis install path, or if Artemis has moved,
boolean foundLocation = false;
for(String location : possibleInstallLocations) { //Search through all default locations.
File file = new File(location + "/Artemis.exe"); //Check to see if any of them actually contain Artemis.exe.
if(file.exists()) {
PreferenceManager.getInstance().setStringPreference(PreferenceManager.PREF_ARTEMIS_INSTALL, location); //If they do, save this location as the Artemis install location.
foundLocation = true;
break;
}
}
if(!foundLocation) { //If we haven't found the location,
JFileChooser chooser = new JFileChooser(); //Prepare a directory select dialog.
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setDialogTitle("Please select Artemis install directory");
chooser.setAcceptAllFileFilterUsed(false);
if(chooser.showOpenDialog(mw) == JFileChooser.APPROVE_OPTION && new File(chooser.getSelectedFile(), "Artemis.exe").exists()) { //If the user has selected a directory containing Artemis.exe,
PreferenceManager.getInstance().setStringPreference(PreferenceManager.PREF_ARTEMIS_INSTALL, chooser.getSelectedFile().getCanonicalPath()); //Save the directory.
}else{ //Otherwise,
System.exit(1); //Clearly, the user isn't ready to launch this program yet.
}
}
}
mw.setVisible(true); //Show the main window.
}
示例9: iterateLookAndFeels
import javax.swing.UIManager; //導入方法依賴的package包/類
protected static void iterateLookAndFeels(final bug8033069NoScrollBar test) throws Exception {
LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
for (LookAndFeelInfo info : lafInfo) {
try {
UIManager.setLookAndFeel(info.getClassName());
System.out.println("Look and Feel: " + info.getClassName());
test.runTest();
} catch (UnsupportedLookAndFeelException e) {
System.out.println("Skipping unsupported LaF: " + info);
}
}
}
示例10: main
import javax.swing.UIManager; //導入方法依賴的package包/類
/**
* Entry point in the editor
*
* @param argv The arguments passed on the command line
*/
public static void main(String[] argv) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
new ParticleEditor();
} catch (Exception e) {
Log.error(e);
}
}
示例11: setNativeLookAndFeel
import javax.swing.UIManager; //導入方法依賴的package包/類
/**
* Try to load native look and feel
*/
public static void setNativeLookAndFeel() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| UnsupportedLookAndFeelException e) {
LOG.error("Could not load native L&F");
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| UnsupportedLookAndFeelException ex) {
LOG.error("Could not load crossplatform L&F");
}
}
}
示例12: initLookAndFeel
import javax.swing.UIManager; //導入方法依賴的package包/類
/** Sets the look-and-feel. */
public static void initLookAndFeel() {
if (!lookAndFeelInit) {
lookAndFeelInit = true;
try {
// LAF specific options that should be done before setting the LAF
// go here
MetalLookAndFeel.setCurrentTheme(new DesertBlue());
// Set the look and feel
UIManager.setLookAndFeel(new com.jgoodies.looks.plastic.PlasticLookAndFeel());
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
}
示例13: iterateLookAndFeels
import javax.swing.UIManager; //導入方法依賴的package包/類
protected static void iterateLookAndFeels(final bug8136998 test) throws Exception {
LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
for (LookAndFeelInfo info : lafInfo) {
try {
UIManager.setLookAndFeel(info.getClassName());
System.out.println("Look and Feel: " + info.getClassName());
test.runTest();
} catch (UnsupportedLookAndFeelException e) {
System.out.println("Skipping unsupported LaF: " + info);
}
}
}
示例14: changeLAF
import javax.swing.UIManager; //導入方法依賴的package包/類
private static void changeLAF() {
String currentLAF = UIManager.getLookAndFeel().toString();
System.out.println(currentLAF);
currentLAF = currentLAF.toLowerCase();
if (currentLAF.contains("aqua") || currentLAF.contains("nimbus")) {
try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
示例15: setUILookAndFeel
import javax.swing.UIManager; //導入方法依賴的package包/類
public static void setUILookAndFeel(){
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch (Throwable e) {
e.printStackTrace();
}
}