下面列出了怎么用javax.swing.plaf.nimbus.NimbusLookAndFeel的API类实例代码及写法,或者点击链接到github查看源代码。
private static void createAndShowGUI() {
try {
UIManager.setLookAndFeel(new TestLookAndFeel());
JLabel label = new JLabel("Test Label");
label.setSize(SIZE, SIZE);
TitledBorder border = new TitledBorder("ABCDEF");
label.setBorder(new TitledBorder(border));
if (useLAF) {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
} else {
UIManager.getDefaults().put("LabelUI", MetalLabelUI.class.getName());
}
SwingUtilities.updateComponentTreeUI(label);
paintToImage(label);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private void testTipOfTheDay() {
var laf = EDT.call(UIManager::getLookAndFeel);
runMenuCommand("Tip of the Day");
var dialog = findDialogByTitle("Tip of the Day");
if (laf instanceof NimbusLookAndFeel) {
findButtonByText(dialog, "Next >").click();
findButtonByText(dialog, "Next >").click();
findButtonByText(dialog, "< Back").click();
} else {
findButtonByText(dialog, "Next Tip").click();
findButtonByText(dialog, "Next Tip").click();
}
findButtonByText(dialog, "Close").click();
dialog.requireNotVisible();
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Robot robot = new Robot();
robot.setAutoDelay(50);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
point = previewPanel.getLocationOnScreen();
}
});
point.translate(5, 5);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Test6919629 t = new Test6919629();
t.test();
System.gc();
t.check();
}
public static void main(String[] args) throws Exception {
nimbus = new NimbusLookAndFeel();
try {
UIManager.setLookAndFeel(nimbus);
} catch (UnsupportedLookAndFeelException e) {
throw new Error("Unable to set Nimbus LAF");
}
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
new ColorCustomizationTest().test();
}
});
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
new JLabel();
UIDefaults uid = UIManager.getDefaults();
uid.putDefaults(new Object[0]);
uid.put("what.ever", "else");
}
});
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Robot robot = new Robot();
robot.setAutoDelay(50);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
point = previewPanel.getLocationOnScreen();
}
});
point.translate(5, 5);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Test6919629 t = new Test6919629();
t.test();
System.gc();
t.check();
}
public static void main(String[] args) throws Exception {
nimbus = new NimbusLookAndFeel();
try {
UIManager.setLookAndFeel(nimbus);
} catch (UnsupportedLookAndFeelException e) {
throw new Error("Unable to set Nimbus LAF");
}
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
new ColorCustomizationTest().test();
}
});
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
new JLabel();
UIDefaults uid = UIManager.getDefaults();
uid.putDefaults(new Object[0]);
uid.put("what.ever", "else");
}
});
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Robot robot = new Robot();
robot.setAutoDelay(50);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
point = previewPanel.getLocationOnScreen();
}
});
point.translate(5, 5);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Test6919629 t = new Test6919629();
t.test();
System.gc();
t.check();
}
public static void main(String[] args) throws Exception {
nimbus = new NimbusLookAndFeel();
try {
UIManager.setLookAndFeel(nimbus);
} catch (UnsupportedLookAndFeelException e) {
throw new Error("Unable to set Nimbus LAF");
}
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
new ColorCustomizationTest().test();
}
});
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
new JLabel();
UIDefaults uid = UIManager.getDefaults();
uid.putDefaults(new Object[0]);
uid.put("what.ever", "else");
}
});
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Robot robot = new Robot();
robot.setAutoDelay(50);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
point = previewPanel.getLocationOnScreen();
}
});
point.translate(5, 5);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Test6919629 t = new Test6919629();
t.test();
System.gc();
t.check();
}
public static void main(String[] args) throws Exception {
nimbus = new NimbusLookAndFeel();
try {
UIManager.setLookAndFeel(nimbus);
} catch (UnsupportedLookAndFeelException e) {
throw new Error("Unable to set Nimbus LAF");
}
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
new ColorCustomizationTest().test();
}
});
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
new JLabel();
UIDefaults uid = UIManager.getDefaults();
uid.putDefaults(new Object[0]);
uid.put("what.ever", "else");
}
});
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Robot robot = new Robot();
robot.setAutoDelay(50);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
point = previewPanel.getLocationOnScreen();
}
});
point.translate(5, 5);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Test6919629 t = new Test6919629();
t.test();
System.gc();
t.check();
}
public static void main(String[] args) throws Exception {
nimbus = new NimbusLookAndFeel();
try {
UIManager.setLookAndFeel(nimbus);
} catch (UnsupportedLookAndFeelException e) {
throw new Error("Unable to set Nimbus LAF");
}
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
new ColorCustomizationTest().test();
}
});
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
new JLabel();
UIDefaults uid = UIManager.getDefaults();
uid.putDefaults(new Object[0]);
uid.put("what.ever", "else");
}
});
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
point = previewPanel.getLocationOnScreen();
}
});
point.translate(5, 5);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Test6919629 t = new Test6919629();
t.test();
System.gc();
t.check();
}
private static boolean tryNimbusLookAndFeel()
throws Exception {
try {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
errorString += e.getMessage();
return false;
}
return true;
}
public static void main(String[] args) throws Exception {
nimbus = new NimbusLookAndFeel();
try {
UIManager.setLookAndFeel(nimbus);
} catch (UnsupportedLookAndFeelException e) {
throw new Error("Unable to set Nimbus LAF");
}
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
new ColorCustomizationTest().test();
}
});
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
new JLabel();
UIDefaults uid = UIManager.getDefaults();
uid.putDefaults(new Object[0]);
uid.put("what.ever", "else");
}
});
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Robot robot = new Robot();
robot.setAutoDelay(50);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
point = previewPanel.getLocationOnScreen();
}
});
point.translate(5, 5);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Test6919629 t = new Test6919629();
t.test();
System.gc();
t.check();
}
public static void main(String[] args) throws Exception {
nimbus = new NimbusLookAndFeel();
try {
UIManager.setLookAndFeel(nimbus);
} catch (UnsupportedLookAndFeelException e) {
throw new Error("Unable to set Nimbus LAF");
}
SwingUtilities.invokeAndWait(new Runnable() {
@Override public void run() {
new ColorCustomizationTest().test();
}
});
}