本文整理汇总了Java中javax.swing.plaf.metal.DefaultMetalTheme类的典型用法代码示例。如果您正苦于以下问题:Java DefaultMetalTheme类的具体用法?Java DefaultMetalTheme怎么用?Java DefaultMetalTheme使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultMetalTheme类属于javax.swing.plaf.metal包,在下文中一共展示了DefaultMetalTheme类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
public static void main(String[] args) {
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
JFrame frame = new JFrame();
frame.setContentPane(new TestPanel());
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
示例2: main
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
/**
* Starts the demo application.
*
* @param args the command line arguments (ignored)
*/
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable() {
public void run()
{
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
MiniDemo demo = new MiniDemo();
demo.setSize(320, 200);
demo.setUndecorated(true);
demo.setVisible(true);
demo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
});
}
示例3: main
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
public static void main(String _a[]) {
try{
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
}catch(Exception e){
e.printStackTrace();
}
new CubemapAssembler();
}
示例4: configureUI
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
private void configureUI() {
Options.setDefaultIconSize(new Dimension(18, 18));
Options.setUseNarrowButtons(this.settings.isUseNarrowButtons());
Options.setTabIconsEnabled(this.settings.isTabIconsEnabled());
UIManager.put("jgoodies.popupDropShadowEnabled", this.settings
.isPopupDropShadowEnabled());
LookAndFeel selectedLaf = this.settings.getSelectedLookAndFeel();
if ((selectedLaf instanceof PlasticLookAndFeel)) {
PlasticLookAndFeel
.setPlasticTheme(this.settings.getSelectedTheme());
PlasticLookAndFeel.setTabStyle(this.settings.getPlasticTabStyle());
PlasticLookAndFeel.setHighContrastFocusColorsEnabled(this.settings
.isPlasticHighContrastFocusEnabled());
} else if (selectedLaf.getClass() == MetalLookAndFeel.class) {
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
}
JRadioButton radio = new JRadioButton();
radio.getUI().uninstallUI(radio);
JCheckBox checkBox = new JCheckBox();
checkBox.getUI().uninstallUI(checkBox);
try {
UIManager.setLookAndFeel(selectedLaf);
} catch (Exception e) {
System.out.println("Can't change L&F: " + e);
}
}
示例5: createThemesMenuItem
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
/**
* Creates a JRadioButtonMenuItem for the Themes menu
*/
public JMenuItem createThemesMenuItem(JMenu menu, String label, String mnemonic,
String accessibleDescription, DefaultMetalTheme theme) {
JRadioButtonMenuItem mi = (JRadioButtonMenuItem) menu.add(new JRadioButtonMenuItem(getString(label)));
themesMenuGroup.add(mi);
mi.setMnemonic(getMnemonic(mnemonic));
mi.getAccessibleContext().setAccessibleDescription(getString(accessibleDescription));
mi.addActionListener(new ChangeThemeAction(this, theme));
return mi;
}
示例6: FreeColLookAndFeel
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
/**
* Initiates a new FreeCol look and feel.
*
* @exception FreeColException If the ui directory could not be found.
*/
public FreeColLookAndFeel() throws FreeColException {
super();
setCurrentTheme(new DefaultMetalTheme() {
protected ColorUIResource getPrimary1() {
return new ColorUIResource(ResourceManager.getColor("lookAndFeel.primary1.color"));
}
protected ColorUIResource getPrimary2() {
return new ColorUIResource(ResourceManager.getColor("lookAndFeel.backgroundSelect.color"));
}
protected ColorUIResource getPrimary3() {
return new ColorUIResource(ResourceManager.getColor("lookAndFeel.primary3.color"));
}
protected ColorUIResource getSecondary1() {
return new ColorUIResource(ResourceManager.getColor("lookAndFeel.secondary1.color"));
}
protected ColorUIResource getSecondary2() {
return new ColorUIResource(ResourceManager.getColor("lookAndFeel.disabled.color"));
}
protected ColorUIResource getSecondary3() {
return new ColorUIResource(ResourceManager.getColor("lookAndFeel.background.color"));
}
public ColorUIResource getMenuDisabledForeground() {
return new ColorUIResource(ResourceManager.getColor("lookAndFeel.disabledMenu.color"));
}
});
}
示例7: setCurrentLookAndFeel
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
/**
* Sets current LAF. The method doesn't update component hierarchy.
*/
@Override
public void setCurrentLookAndFeel(UIManager.LookAndFeelInfo lookAndFeelInfo) {
if (findLaf(lookAndFeelInfo.getClassName()) == null) {
LOG.error("unknown LookAndFeel : " + lookAndFeelInfo);
return;
}
try {
LookAndFeel laf = ((LookAndFeel)Class.forName(lookAndFeelInfo.getClassName()).newInstance());
if (laf instanceof MetalLookAndFeel) {
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
}
boolean dark = laf instanceof BuildInLookAndFeel && ((BuildInLookAndFeel)laf).isDark();
JBColor.setDark(dark);
UIModificationTracker.getInstance().incModificationCount();
IconLoader.setUseDarkIcons(dark);
fireUpdate();
UIManager.setLookAndFeel(laf);
}
catch (Exception e) {
Messages.showMessageDialog(IdeBundle.message("error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()), CommonBundle.getErrorTitle(),
Messages.getErrorIcon());
return;
}
myCurrentLaf = lookAndFeelInfo;
checkLookAndFeel(lookAndFeelInfo, false);
}
示例8: FreeColLookAndFeel
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
/**
* Initiates a new FreeCol look and feel.
*
* @exception FreeColException If the ui directory could not be found.
*/
public FreeColLookAndFeel() throws FreeColException {
super();
setCurrentTheme(new DefaultMetalTheme() {
@Override
protected ColorUIResource getPrimary1() {
return new ColorUIResource(ResourceManager.getColor("color.primary1.LookAndFeel"));
}
@Override
protected ColorUIResource getPrimary2() {
return new ColorUIResource(ResourceManager.getColor("color.backgroundSelect.LookAndFeel"));
}
@Override
protected ColorUIResource getPrimary3() {
return new ColorUIResource(ResourceManager.getColor("color.primary3.LookAndFeel"));
}
@Override
protected ColorUIResource getSecondary1() {
return new ColorUIResource(ResourceManager.getColor("color.secondary1.LookAndFeel"));
}
@Override
protected ColorUIResource getSecondary2() {
return new ColorUIResource(ResourceManager.getColor("color.disabled.LookAndFeel"));
}
@Override
protected ColorUIResource getSecondary3() {
return new ColorUIResource(ResourceManager.getColor("color.background.LookAndFeel"));
}
@Override
public ColorUIResource getMenuDisabledForeground() {
return new ColorUIResource(ResourceManager.getColor("color.disabledMenu.LookAndFeel"));
}
});
}
示例9: buildMenus
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
protected void buildMenus() {
menuBar = new JMenuBar();
menuBar.setOpaque(true);
JMenu file = buildFileMenu();
JMenu edit = buildEditMenu();
JMenu views = buildViewsMenu();
JMenu speed = buildSpeedMenu();
JMenu help = buildHelpMenu();
// load a theme from a text file
MetalTheme myTheme = null;
try {
InputStream istream = getClass().getResourceAsStream(
"/resources/MyTheme.theme");
myTheme = new PropertiesMetalTheme(istream);
} catch (NullPointerException e) {
System.out.println(e);
}
// build an array of themes
MetalTheme[] themes = { new OceanTheme(),
new DefaultMetalTheme(),
new GreenMetalTheme(),
new AquaMetalTheme(),
new KhakiMetalTheme(),
new DemoMetalTheme(),
new ContrastMetalTheme(),
new BigContrastMetalTheme(),
myTheme };
// put the themes in a menu
JMenu themeMenu = new MetalThemeMenu("Theme", themes);
menuBar.add(file);
menuBar.add(edit);
menuBar.add(views);
menuBar.add(themeMenu);
menuBar.add(speed);
menuBar.add(help);
setJMenuBar(menuBar);
}
示例10: main
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
public static void main(String[] args) throws InvocationTargetException, InterruptedException {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
JComponent component = new JLabel();
Icon horizontalThumbIcon = UIManager.getIcon("Slider.horizontalThumbIcon");
Icon verticalThumbIcon = UIManager.getIcon("Slider.verticalThumbIcon");
Graphics g = new BufferedImage(100, 100, BufferedImage.TYPE_4BYTE_ABGR).getGraphics();
horizontalThumbIcon.paintIcon(component, g, 0, 0);
verticalThumbIcon.paintIcon(component, g, 0, 0);
}
});
}
示例11: Theme
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
/**
* This constructor reads all the values it needs from the
* GUIResourceBundle. It uses intelligent defaults if properties
* are not specified.
**/
public Theme(GUIResourceBundle resources, String name) {
// Use this theme object to get default font values from
DefaultMetalTheme defaultTheme = new DefaultMetalTheme();
// Look up the display name of the theme
displayName = resources.getString(name + ".name", null);
// Look up the fonts for the theme
Font control = resources.getFont(name + ".controlFont", null);
Font menu = resources.getFont(name + ".menuFont", null);
Font small = resources.getFont(name + ".smallFont", null);
Font system = resources.getFont(name + ".systemFont", null);
Font user = resources.getFont(name + ".userFont", null);
Font title = resources.getFont(name + ".titleFont", null);
// Convert fonts to FontUIResource, or get defaults
if (control != null) controlFont = new FontUIResource(control);
else controlFont = defaultTheme.getControlTextFont();
if (menu != null) menuFont = new FontUIResource(menu);
else menuFont = defaultTheme.getMenuTextFont();
if (small != null) smallFont = new FontUIResource(small);
else smallFont = defaultTheme.getSubTextFont();
if (system != null) systemFont = new FontUIResource(system);
else systemFont = defaultTheme.getSystemTextFont();
if (user != null) userFont = new FontUIResource(user);
else userFont = defaultTheme.getUserTextFont();
if (title != null) titleFont = new FontUIResource(title);
else titleFont = defaultTheme.getWindowTitleFont();
// Look up primary and secondary colors
Color primary = resources.getColor(name + ".primary", null);
Color secondary = resources.getColor(name + ".secondary", null);
// Derive all six colors from these two, using defaults if needed
if (primary != null) primary1 = new ColorUIResource(primary);
else primary1 = new ColorUIResource(102, 102, 153);
primary2 = new ColorUIResource(primary1.brighter());
primary3 = new ColorUIResource(primary2.brighter());
if (secondary != null) secondary1 = new ColorUIResource(secondary);
else secondary1 = new ColorUIResource(102, 102, 102);
secondary2 = new ColorUIResource(secondary1.brighter());
secondary3 = new ColorUIResource(secondary2.brighter());
}
示例12: createMetalTheme
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
protected DefaultMetalTheme createMetalTheme() {
return new DarculaMetalTheme();
}
示例13: createMetalTheme
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
@Override
protected DefaultMetalTheme createMetalTheme() {
return new IdeaBlueMetalTheme();
}
示例14: cycleAddons
import javax.swing.plaf.metal.DefaultMetalTheme; //导入依赖的package包/类
/**
* Go through all existing LookAndFeelAddons. This leads all registered
* {@link org.jdesktop.swingx.plaf.ComponentAddon} to initialize/uninitialize
* themselves.
*/
public static void cycleAddons(JComponent component) throws Exception {
LookAndFeelAddons.setAddon(MacOSXLookAndFeelAddons.class.getName());
component.updateUI();
MetalTheme oldTheme = MetalLookAndFeel.getCurrentTheme();
try {
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
LookAndFeelAddons.setAddon(MetalLookAndFeelAddons.class.getName());
component.updateUI();
MetalLookAndFeel.setCurrentTheme(new OceanTheme());
LookAndFeelAddons.setAddon(MetalLookAndFeelAddons.class.getName());
component.updateUI();
} finally {
MetalLookAndFeel.setCurrentTheme(oldTheme);
}
LookAndFeelAddons.setAddon(MotifLookAndFeelAddons.class.getName());
component.updateUI();
LookAndFeelAddons.setAddon(WindowsLookAndFeelAddons.class.getName());
component.updateUI();
String property = UIManager.getString("win.xpstyle.name");
try {
UIManager.put("win.xpstyle.name",
WindowsLookAndFeelAddons.HOMESTEAD_VISUAL_STYLE);
LookAndFeelAddons.setAddon(WindowsClassicLookAndFeelAddons.class
.getName());
component.updateUI();
UIManager.put("win.xpstyle.name",
WindowsLookAndFeelAddons.SILVER_VISUAL_STYLE);
LookAndFeelAddons.setAddon(WindowsClassicLookAndFeelAddons.class
.getName());
component.updateUI();
UIManager.put("win.xpstyle.name", null);
LookAndFeelAddons.setAddon(WindowsClassicLookAndFeelAddons.class
.getName());
component.updateUI();
} finally {
UIManager.put("win.xpstyle.name", property);
}
}