本文整理汇总了Java中javax.swing.UIManager.getSystemLookAndFeelClassName方法的典型用法代码示例。如果您正苦于以下问题:Java UIManager.getSystemLookAndFeelClassName方法的具体用法?Java UIManager.getSystemLookAndFeelClassName怎么用?Java UIManager.getSystemLookAndFeelClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.UIManager
的用法示例。
在下文中一共展示了UIManager.getSystemLookAndFeelClassName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDefaultLookAndFeel
import javax.swing.UIManager; //导入方法依赖的package包/类
/** Tries to set default L&F according to platform.
* Uses:
* Metal L&F on Linux and Solaris
* Windows L&F on Windows
* Aqua L&F on Mac OS X
* System L&F on other OS
*/
public static void setDefaultLookAndFeel () {
String uiClassName;
if (Utilities.isWindows()) {
uiClassName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; //NOI18N
} else if (Utilities.isMac()) {
uiClassName = "apple.laf.AquaLookAndFeel"; //NOI18N
} else if (Utilities.isUnix()) {
uiClassName = "javax.swing.plaf.metal.MetalLookAndFeel"; //NOI18N
} else {
uiClassName = UIManager.getSystemLookAndFeelClassName();
}
if (uiClassName.equals(UIManager.getLookAndFeel().getClass().getName())) {
//Desired L&F is already set
return;
}
try {
UIManager.setLookAndFeel(uiClassName);
} catch (Exception ex) {
System.err.println("Cannot set L&F " + uiClassName); //NOI18N
System.err.println("Exception:" + ex.getMessage()); //NOI18N
ex.printStackTrace();
}
}
示例2: setTheme
import javax.swing.UIManager; //导入方法依赖的package包/类
private void setTheme() {
try {
/*
* TODO BUG
*
* A Fatal Error occurs while setting GTK look and feel on Ubuntu 16.04
* (com.sun.java.swing.plaf.gtk.GTKLookAndFeel).
*
*/
final String LaF = UIManager.getSystemLookAndFeelClassName();
if ("com.sun.java.swing.plaf.gtk.GTKLookAndFeel".equals(LaF)) {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} else {
UIManager.setLookAndFeel(LaF);
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| UnsupportedLookAndFeelException e1) {
e1.printStackTrace();
}
}
示例3: main
import javax.swing.UIManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
robot = new Robot();
String name = UIManager.getSystemLookAndFeelClassName();
try {
UIManager.setLookAndFeel(name);
} catch (ClassNotFoundException | InstantiationException |
IllegalAccessException | UnsupportedLookAndFeelException e) {
throw new RuntimeException("Test Failed");
}
createUI();
robot.waitForIdle();
executeTest();
if (!"".equals(errorMessage)) {
throw new RuntimeException(errorMessage);
}
}
示例4: getDefaultLookAndFeelClassName
import javax.swing.UIManager; //导入方法依赖的package包/类
public static String getDefaultLookAndFeelClassName(
) {
switch (UiMode.getCurrentUiMode()) {
case SWING:
String className = UIManager.getSystemLookAndFeelClassName();
// if the default look and feel is the cross-platform one, we might
// need to correct this choice. E.g. - KDE, where GTK look and feel
// would be much more appropriate
if (className.equals(UIManager.getCrossPlatformLookAndFeelClassName())) {
// if the current platform is Linux and the desktop manager is
// KDE, then we should try to use the GTK look and feel
try {
if (System.getProperty("os.name").contains("Linux") &&
(System.getenv("KDE_FULL_SESSION") != null)) {
// check whether the GTK look and feel class is
// available -- we'll get CNFE if it is not and it will
// not be set
Class.forName(LookAndFeelType.GTK.getClassName());
className = LookAndFeelType.GTK.getClassName();
}
} catch (ClassNotFoundException e) {
ErrorManager.notifyDebug(ResourceUtils.getString(UiUtils.class,
RESOURCE_FAILED_TO_FORCE_GTK), e);
}
}
return className;
default:
return null;
}
}
示例5: create
import javax.swing.UIManager; //导入方法依赖的package包/类
/**
* This creates editors and parse specification for show meta model.
*
* @throws CoreException
*/
public void create() throws CoreException {
try {
/*
* TODO BUG
*
* A Fatal Error occurs while setting GTK look and feel on Ubuntu 16.04
* (com.sun.java.swing.plaf.gtk.GTKLookAndFeel).
*
*/
final String LaF = UIManager.getSystemLookAndFeelClassName();
if ("com.sun.java.swing.plaf.gtk.GTKLookAndFeel".equals(LaF)) {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} else {
UIManager.setLookAndFeel(LaF);
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
final int index = 0;
this.textEditor = new Editor();
this.addTextPage(index);
this.addModelPage(index);
MetaModelEditor.xmlFileName = Util.canon(AlloyUtilities.getLocationForMetamodel(MetaModelEditor.title));
MetaModelEditor.frame = SWT_AWT.new_Frame(this.modelEditor);
MetaModelEditor.myState = null;
MetaModelEditor.graph = null;
MetaModelEditor.file = null;
}
示例6: main
import javax.swing.UIManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
if (!Platform.isWindows()) {
System.out.println("Only Windows platform test. Test is skipped.");
System.out.println("ok");
return;
}
final String lafClassName = UIManager.getSystemLookAndFeelClassName();
lafClass = Class.forName(lafClassName);
UIManager.setLookAndFeel(lafClassName);
try {
SwingUtilities.invokeAndWait(() -> {
frame = new JFrame();
frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setup(frame);
});
final Robot robot = new Robot();
robot.waitForIdle();
robot.setAutoDelay(20);
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_F);
robot.keyRelease(KeyEvent.VK_F);
robot.keyRelease(KeyEvent.VK_ALT);
robot.waitForIdle();
checkMnemonics();
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_S);
robot.keyRelease(KeyEvent.VK_S);
robot.keyRelease(KeyEvent.VK_ALT);
robot.waitForIdle();
checkMnemonics();
System.out.println("ok");
} finally {
if (frame != null) { frame.dispose(); }
}
}
示例7: applyUserPreferences
import javax.swing.UIManager; //导入方法依赖的package包/类
/**
* Reads the user config data and applies the required settings.
* This must be called <b>after</b> {@link Gate#init()} but <b>before</b>
* any GUI components are created.
*/
public static void applyUserPreferences(){
//look and feel
String lnfClassName;
if(System.getProperty("swing.defaultlaf") != null) {
lnfClassName = System.getProperty("swing.defaultlaf");
} else {
lnfClassName = Gate.getUserConfig().
getString(GateConstants.LOOK_AND_FEEL);
}
if(lnfClassName == null){
//if running on Linux, default to Metal rather than GTK because GTK LnF
//doesn't play nicely with most Gnome themes
if(System.getProperty("os.name").toLowerCase().indexOf("linux") != -1){
//running on Linux
lnfClassName = UIManager.getCrossPlatformLookAndFeelClassName();
}else{
lnfClassName = UIManager.getSystemLookAndFeelClassName();
}
}
try {
UIManager.setLookAndFeel(lnfClassName);
} catch(Exception e) {
System.err.print("Could not set your preferred Look and Feel. The error was:\n" +
e.toString() + "\nReverting to using Java Look and Feel");
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}catch(Exception e1) {
//we just can't catch a break here. Let's forget about look and feel.
System.err.print(
"Could not set the cross-platform Look and Feel either. The error was:\n" +
e1.toString() + "\nGiving up on Look and Feel.");
}
}
Gate.getUserConfig().put(GateConstants.LOOK_AND_FEEL, lnfClassName);
//read the user config data
OptionsMap userConfig = Gate.getUserConfig();
//text font
Font font = userConfig.getFont(GateConstants.TEXT_COMPONENTS_FONT);
if(font == null){
font = UIManager.getFont("TextPane.font");
}
if(font != null){
OptionsDialog.setTextComponentsFont(font);
}
//menus font
font = userConfig.getFont(GateConstants.MENUS_FONT);
if(font == null){
font = UIManager.getFont("Menu.font");
}
if(font != null){
OptionsDialog.setMenuComponentsFont(font);
}
//other gui font
font = userConfig.getFont(GateConstants.OTHER_COMPONENTS_FONT);
if(font == null){
font = UIManager.getFont("Button.font");
}
if(font != null){
OptionsDialog.setComponentsFont(font);
}
}
示例8: showViz
import javax.swing.UIManager; //导入方法依赖的package包/类
private void showViz() {
if (AlloySolutionSelectionPage.container == null) {
return;
}
if (!AlloyUtilities.isExists()) {
if (AlloySolutionSelectionPage.frame != null) {
if (AlloySolutionSelectionPage.frame.getComponentCount() > 0) {
AlloySolutionSelectionPage.frame.removeAll();
}
AlloySolutionSelectionPage.frame.add(new JPanel());
} else if (AlloySolutionSelectionPage.frame == null) {
AlloySolutionSelectionPage.frame = SWT_AWT.new_Frame(AlloySolutionSelectionPage.container);
AlloySolutionSelectionPage.frame.add(new JPanel());
}
return;
}
AlloySolutionSelectionPage.f = new File(getLocation());
try {
if (!AlloySolutionSelectionPage.f.exists()) {
throw new IOException("File " + getLocation() + " does not exist.");
}
final AlloyInstance instance =
StaticInstanceReader.parseInstance(AlloySolutionSelectionPage.f);
AlloyUtilities.setAllImpactsAndChanges(instance);
AlloySolutionSelectionPage.myState = new VizState(instance);
// FE
AlloySolutionSelectionPage.myState.mergeArrows.put(null, false);
if (AlloySolutionSelectionPage.frame == null) {
AlloySolutionSelectionPage.frame = SWT_AWT.new_Frame(AlloySolutionSelectionPage.container);
}
if (AlloySolutionSelectionPage.graph != null
&& AlloySolutionSelectionPage.frame.getComponent(0) != null) {
AlloySolutionSelectionPage.frame.remove(AlloySolutionSelectionPage.graph);
}
try {
/*
* TODO BUG
*
* A Fatal Error occurs while setting GTK look and feel on Ubuntu 16.04
* (com.sun.java.swing.plaf.gtk.GTKLookAndFeel).
*
*/
final String LaF = UIManager.getSystemLookAndFeelClassName();
if ("com.sun.java.swing.plaf.gtk.GTKLookAndFeel".equals(LaF)) {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} else {
UIManager.setLookAndFeel(LaF);
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| UnsupportedLookAndFeelException e1) {
e1.printStackTrace();
}
AlloySolutionSelectionPage.graph =
new VizGraphPanel(AlloySolutionSelectionPage.myState, false);
AlloySolutionSelectionPage.frame.removeAll();
AlloySolutionSelectionPage.frame.add(AlloySolutionSelectionPage.graph);
AlloySolutionSelectionPage.frame.setVisible(true);
AlloySolutionSelectionPage.frame.setAlwaysOnTop(true);
AlloySolutionSelectionPage.graph.alloyGetViewer().alloyRepaint();
} catch (final Err | IOException e) {
e.printStackTrace();
setErrorMessage("An error has occured while Alloy visualization.");
}
}