当前位置: 首页>>代码示例>>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;未经允许,请勿转载。