本文整理汇总了Java中javax.swing.plaf.metal.MetalLookAndFeel类的典型用法代码示例。如果您正苦于以下问题:Java MetalLookAndFeel类的具体用法?Java MetalLookAndFeel怎么用?Java MetalLookAndFeel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetalLookAndFeel类属于javax.swing.plaf.metal包,在下文中一共展示了MetalLookAndFeel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的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);
}
示例2: testSinglePlatformInstall
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
public void testSinglePlatformInstall () throws IOException, UnsupportedLookAndFeelException {
UIManager.setLookAndFeel(new MetalLookAndFeel());
InstallerRegistry regs = InstallerRegistryAccessor.prepareForUnitTest(new GeneralPlatformInstall[] {
new FileBasedPlatformInstall ("FileBased1", Collections.<WizardDescriptor.Panel<WizardDescriptor>>singletonList(
new Panel ("FileBased1_panel1")
))
});
PlatformInstallIterator iterator = PlatformInstallIterator.create();
WizardDescriptor wd = new WizardDescriptor (iterator);
iterator.initialize(wd);
assertEquals("Invalid state", 1, iterator.getPanelIndex());
WizardDescriptor.Panel panel = iterator.current();
assertTrue ("Invalid panel",panel instanceof LocationChooser.Panel);
((JFileChooser)panel.getComponent()).setSelectedFile(this.getWorkDir()); //Select some folder
assertTrue ("LocationChooser is not valid after folder was selected",panel.isValid());
assertTrue ("Should have next panel",iterator.hasNext());
assertFalse ("Should not have previous panel", iterator.hasPrevious());
iterator.nextPanel();
assertEquals("Invalid state", 2, iterator.getPanelIndex());
panel = iterator.current();
assertEquals("Invalid panel","FileBased1_panel1",panel.getComponent().getName());
assertFalse ("Should not have next panel",iterator.hasNext());
assertTrue ("Should have previous panel", iterator.hasPrevious());
}
示例3: updateUI
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
/** Overridden to use CleanComboUI on Metal L&F to avoid extra borders */
@Override
public void updateUI() {
LookAndFeel lf = UIManager.getLookAndFeel();
String id = lf.getID();
boolean useClean = tableUI && (lf instanceof MetalLookAndFeel
|| "GTK".equals(id) //NOI18N
|| "Nimbus".equals(id) //NOI18N
|| ("Aqua".equals(id) && checkMacSystemVersion()) // NOI18N
|| PropUtils.isWindowsVistaLaF() //#217957
|| "Kunststoff".equals(id)); //NOI18N
if (useClean) {
super.setUI(PropUtils.createComboUI(this, tableUI));
} else {
super.updateUI();
}
if (tableUI & getEditor().getEditorComponent() instanceof JComponent) {
((JComponent) getEditor().getEditorComponent()).setBorder(null);
}
}
示例4: installPerLFDefaults
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
private void installPerLFDefaults() {
boolean isLFChange = curCustoms != null;
curCustoms = findCustoms();
if (curCustoms != null) {
Integer in = (Integer) UIManager.get(LFCustoms.CUSTOM_FONT_SIZE); //NOI18N
if (in == null && UIManager.getLookAndFeel().getClass() == MetalLookAndFeel.class) {
in = new Integer (11);
}
//#161761: Do not want to use font size param for GTK L&F because it causes mixed font size
if ((in != null) && !UIUtils.isGtkLF()) {
AllLFCustoms.initCustomFontSize (in.intValue());
}
installLFCustoms (curCustoms);
if (isLFChange) {
//make sure UIBootstrapValue.Lazy instances really get a chance
//to replace their values
loadAllLazyValues (curCustoms);
}
curCustoms.disposeValues();
}
}
示例5: isOceanTheme
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
private static boolean isOceanTheme() {
if (!inSandbox) {
try {
java.lang.reflect.Field field = MetalLookAndFeel.class.getDeclaredField("currentTheme");
field.setAccessible(true);
Object theme = field.get(null);
return "javax.swing.plaf.metal.OceanTheme".equals(theme.getClass().getName());
} catch (Exception ex) {
// We're in a sandbox and can't access the field
inSandbox = true;
}
}
if (!checkedForOcean) {
checkedForOcean = true;
checkForOcean();
}
return usingOcean;
}
示例6: actionPerformed
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
String numStr = e.getActionCommand();
MetalTheme selectedTheme = themes[Integer.parseInt(numStr)];
MetalLookAndFeel.setCurrentTheme(selectedTheme);
try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
} catch (Exception ex) {
System.out.println("Failed loading Metal");
System.out.println(ex);
}
}
示例7: main
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
tempDir = System.getProperty("java.io.tmpdir");
if (tempDir.length() == 0) { //'java.io.tmpdir' isn't guaranteed to be defined
tempDir = System.getProperty("user.home");
}
System.out.println("Temp directory: " + tempDir);
UIManager.setLookAndFeel(new MetalLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
HackedFileChooser openChooser = new HackedFileChooser();
openChooser.setUI(new MetalFileChooserUI(openChooser));
openChooser.setCurrentDirectory(new File(tempDir));
}
});
}
示例8: test
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
void test() {
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
throw new Error("Cannot set Metal LAF");
}
// Render text using background color
UIManager.put("textInactiveText", TEST_COLOR);
test(new JLabel(html));
test(new JButton(html));
JEditorPane pane = new JEditorPane("text/html", html);
pane.setDisabledTextColor(TEST_COLOR);
test(pane);
}
示例9: main
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
SwingUtilities.invokeAndWait(bug7170310::createAndShowUI);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
toolkit.realSync();
for (int i = 0; i < TABS_NUMBER; i++) {
SwingUtilities.invokeAndWait(bug7170310::addTab);
toolkit.realSync();
}
SwingUtilities.invokeAndWait(bug7170310::check);
if (exception != null) {
System.out.println("Test failed: " + exception.getMessage());
throw exception;
} else {
System.out.printf("Test passed");
}
} finally {
frame.dispose();
}
}
示例10: main
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
public static void main(String[] args) {
UIDefaults table= new MetalLookAndFeel().getDefaults();
test(table.get("ToolBar.rolloverBorder"),
"javax.swing.plaf.metal.MetalBorders$ButtonBorder",
"javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
test(table.get("ToolBar.nonrolloverBorder"),
"javax.swing.plaf.metal.MetalBorders$ButtonBorder",
"javax.swing.plaf.metal.MetalBorders$RolloverMarginBorder");
test(table.get("RootPane.frameBorder"),
"javax.swing.plaf.metal.MetalBorders$FrameBorder");
test(table.get("RootPane.plainDialogBorder"),
"javax.swing.plaf.metal.MetalBorders$DialogBorder");
test(table.get("RootPane.informationDialogBorder"),
"javax.swing.plaf.metal.MetalBorders$DialogBorder");
test(table.get("RootPane.errorDialogBorder"),
"javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder");
test(table.get("RootPane.colorChooserDialogBorder"),
"javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
test(table.get("RootPane.fileChooserDialogBorder"),
"javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
test(table.get("RootPane.questionDialogBorder"),
"javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder");
test(table.get("RootPane.warningDialogBorder"),
"javax.swing.plaf.metal.MetalBorders$WarningDialogBorder");
}
示例11: main
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
SwingUtilities.invokeAndWait(bug7170310::createAndShowUI);
sync();
for (int i = 0; i < TABS_NUMBER; i++) {
SwingUtilities.invokeAndWait(bug7170310::addTab);
sync();
}
SwingUtilities.invokeAndWait(bug7170310::check);
if (exception != null) {
System.out.println("Test failed: " + exception.getMessage());
throw exception;
} else {
System.out.printf("Test passed");
}
} finally {
if (frame != null) { frame.dispose(); }
}
}
示例12: main
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(() -> {
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
} catch (Exception e) {
throw new RuntimeException(e);
}
if (!testSliderThumb(true)) {
throw new RuntimeException("Horizontal Slider Thumb is not scaled!");
}
if (!testSliderThumb(false)) {
throw new RuntimeException("Vertical Slider Thumb is not scaled!");
}
});
}
示例13: createAndShowGUI
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
private static void createAndShowGUI() {
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
} catch (Exception e) {
throw new RuntimeException(e);
}
frame = new JFrame();
frame.setSize(300, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel(new BorderLayout());
button = new JButton("");
panel.add(button);
frame.getContentPane().add(panel);
frame.setVisible(true);
}
示例14: main
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
SwingUtilities.invokeAndWait(bug7170310::createAndShowUI);
sync();
for (int i = 0; i < TABS_NUMBER; i++) {
SwingUtilities.invokeAndWait(bug7170310::addTab);
sync();
}
SwingUtilities.invokeAndWait(bug7170310::check);
if (exception != null) {
System.out.println("Test failed: " + exception.getMessage());
throw exception;
} else {
System.out.printf("Test passed");
}
} finally {
frame.dispose();
}
}
示例15: getBestMatchAddonClassName
import javax.swing.plaf.metal.MetalLookAndFeel; //导入依赖的package包/类
/**
* Based on the current look and feel (as returned by
* <code>UIManager.getLookAndFeel()</code>), this method returns
* the name of the closest <code>LookAndFeelAddons</code> to use.
*
* @return the addon matching the currently installed look and feel
*/
public static String getBestMatchAddonClassName() {
String lnf = UIManager.getLookAndFeel().getClass().getName();
String addon;
if (UIManager.getCrossPlatformLookAndFeelClassName().equals(lnf)) {
addon = MetalLookAndFeelAddons.class.getName();
} else if (UIManager.getSystemLookAndFeelClassName().equals(lnf)) {
addon = getSystemAddonClassName();
} else if ("com.sun.java.swing.plaf.windows.WindowsLookAndFeel".equals(lnf) ||
"com.jgoodies.looks.windows.WindowsLookAndFeel".equals(lnf)) {
if (OS.isUsingWindowsVisualStyles()) {
addon = WindowsLookAndFeelAddons.class.getName();
} else {
addon = WindowsClassicLookAndFeelAddons.class.getName();
}
} else if ("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"
.equals(lnf)) {
addon = WindowsClassicLookAndFeelAddons.class.getName();
} else if (UIManager.getLookAndFeel() instanceof MetalLookAndFeel) {
// for JGoodies and other sub-l&fs of Metal
addon = MetalLookAndFeelAddons.class.getName();
} else {
addon = getSystemAddonClassName();
}
return addon;
}