當前位置: 首頁>>代碼示例>>Java>>正文


Java UIManager.setLookAndFeel方法代碼示例

本文整理匯總了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");
            }
        });
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:DesktopPaneBackgroundTest.java

示例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());
	}	
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:19,代碼來源:BenchmarkMonitor.java

示例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();
}
 
開發者ID:Moudoux,項目名稱:EMC-Installer,代碼行數:21,代碼來源:Installer.java

示例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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:bug8031573.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:MaximizedFrameTest.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:Metalworks.java

示例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());
    }

}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:9,代碼來源:Aplicacao.java

示例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.
}
 
開發者ID:Michaelkielstra,項目名稱:Diana,代碼行數:35,代碼來源:Main.java

示例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);
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:bug8033069NoScrollBar.java

示例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);
	}
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:15,代碼來源:ParticleEditor.java

示例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");
		}
	}
}
 
開發者ID:michaelnetter,項目名稱:dracoon-dropzone,代碼行數:18,代碼來源:Util.java

示例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);
        }
    }
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:16,代碼來源:Options.java

示例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);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:bug8136998.java

示例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();
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:bug8033699.java

示例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();
	}
}
 
開發者ID:kevingilboy,項目名稱:COE1186,代碼行數:9,代碼來源:TrackControllerGUI.java


注:本文中的javax.swing.UIManager.setLookAndFeel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。