本文整理汇总了Java中javax.swing.plaf.metal.MetalTheme类的典型用法代码示例。如果您正苦于以下问题:Java MetalTheme类的具体用法?Java MetalTheme怎么用?Java MetalTheme使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetalTheme类属于javax.swing.plaf.metal包,在下文中一共展示了MetalTheme类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MetalThemeMenu
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
super(name);
themes = themeArray;
ButtonGroup group = new ButtonGroup();
for (int i = 0; i < themes.length; i++) {
JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
getName());
group.add(item);
add(item);
item.setActionCommand(i + "");
item.addActionListener(this);
if (i == 0) {
item.setSelected(true);
}
}
}
示例2: actionPerformed
import javax.swing.plaf.metal.MetalTheme; //导入依赖的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);
}
}
示例3: getInstalledThemes
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
public static List getInstalledThemes()
/* 518: */ {
/* 519: 795 */ if (null == installedThemes) {
/* 520: 796 */ installDefaultThemes();
/* 521: */ }
/* 522: 798 */ Collections.sort(installedThemes, new Comparator()
/* 523: */ {
/* 524: */ public int compare(Object o1, Object o2)
/* 525: */ {
/* 526: 800 */ MetalTheme theme1 = (MetalTheme)o1;
/* 527: 801 */ MetalTheme theme2 = (MetalTheme)o2;
/* 528: 802 */ return theme1.getName().compareTo(theme2.getName());
/* 529: */ }
/* 530: 805 */ });
/* 531: 806 */ return installedThemes;
/* 532: */ }
示例4: getPlasticTheme
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
public static PlasticTheme getPlasticTheme()
/* 565: */ {
/* 566: 887 */ if (LookUtils.IS_JAVA_5_OR_LATER)
/* 567: */ {
/* 568: 888 */ MetalTheme theme = getCurrentTheme0();
/* 569: 889 */ if ((theme instanceof PlasticTheme)) {
/* 570: 890 */ return (PlasticTheme)theme;
/* 571: */ }
/* 572: */ }
/* 573: 892 */ PlasticTheme uimanagerTheme = (PlasticTheme)UIManager.get(THEME_KEY);
/* 574: 893 */ if (uimanagerTheme != null) {
/* 575: 894 */ return uimanagerTheme;
/* 576: */ }
/* 577: 896 */ PlasticTheme initialTheme = createMyDefaultTheme();
/* 578: 897 */ setPlasticTheme(initialTheme);
/* 579: 898 */ return initialTheme;
/* 580: */ }
示例5: themeSelectionChanged
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
/**
* Handle theme selection changed
* @param e
*/
private void themeSelectionChanged(final ListSelectionEvent e)
{
if (m_setting)
return;
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try
{
ValueNamePair laf = lookList.getSelectedValue();
ValueNamePair theme = themeList.getSelectedValue();
LookAndFeel currentLaf = UIManager.getLookAndFeel();
MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme();
AdempierePLAF.setPLAF(laf, theme, false);
previewPanel.refresh(currentLaf, currentTheme);
SwingUtilities.updateComponentTreeUI(previewPanel);
updatePreviewComponents();
setLFSelection();
}
finally
{
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
this.repaint();
}
}
示例6: lookAndFeelSelectionChanged
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
/**
* Handle look and feel selection changed
* @param e
*/
private void lookAndFeelSelectionChanged(final ListSelectionEvent e)
{
if (m_setting)
return;
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try
{
ValueNamePair laf = lookList.getSelectedValue();
LookAndFeel currentLaf = UIManager.getLookAndFeel();
MetalTheme currentTheme = MetalLookAndFeel.getCurrentTheme();
AdempierePLAF.setPLAF(laf, null, false);
previewPanel.refresh(currentLaf, currentTheme);
SwingUtilities.updateComponentTreeUI(previewPanel);
updatePreviewComponents();
setLFSelection();
}
finally
{
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
this.repaint();
}
}
示例7: actionPerformed
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void actionPerformed(ActionEvent actionEvent) {
try {
String lookAndFeelClassName = actionEvent.getActionCommand();
Class<LookAndFeel> lookAndFeelClass = (Class<LookAndFeel>) Class.forName(lookAndFeelClassName);
LookAndFeel lookAndFeel = lookAndFeelClass.newInstance();
if (lookAndFeel instanceof MetalThemeProvider) {
MetalTheme theme = ((MetalThemeProvider) lookAndFeel).getMetalTheme();
MetalLookAndFeel.setCurrentTheme(theme);
}
UIManager.setLookAndFeel(lookAndFeel);
for (Window window : JFrame.getWindows()) {
SwingUtilities.updateComponentTreeUI(window);
window.validate();
window.repaint();
}
} catch (Exception exception) {
exception.printStackTrace();
JOptionPane.showMessageDialog(null, "Can't change look and feel", "Invalid PLAF", JOptionPane.ERROR_MESSAGE);
}
}
示例8: getInstalledThemes
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
/**
* Lazily initializes and returns the {@code List} of installed
* color themes.
*
* @return a list of installed color/font themes
*/
public static List getInstalledThemes() {
if (null == installedThemes) {
installDefaultThemes();
}
Collections.sort(installedThemes, new Comparator() {
public int compare(Object o1, Object o2) {
MetalTheme theme1 = (MetalTheme) o1;
MetalTheme theme2 = (MetalTheme) o2;
return theme1.getName().compareTo(theme2.getName());
}
});
return installedThemes;
}
示例9: MetalLayoutStyle
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
public MetalLayoutStyle() {
isOcean = false;
try {
Method method = MetalLookAndFeel.class.
getMethod("getCurrentTheme", (Class[])null);
isOcean = ((MetalTheme)method.invoke(null, (Object[])null)).
getName() == "Ocean";
} catch (NoSuchMethodException nsme) {
} catch (IllegalAccessException iae) {
} catch (IllegalArgumentException iae2) {
} catch (InvocationTargetException ite) {
}
}
示例10: createThemesMenuItem
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
/**
* Creates a JRadioButtonMenuItem for the Themes menu.
*
* @param menu the menu
* @param label the label
* @param mnemonic the mnemonic
* @param accessibleDescription the accessible description
* @param theme the theme
* @return the j menu item
*/
public JMenuItem createThemesMenuItem(JMenu menu, String label, String mnemonic,
String accessibleDescription, MetalTheme 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;
}
示例11: refresh
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
/**
* Refresh look and feel preview, reset to original setting after
* refresh.
* @param currentLaf Current Look and feel
* @param currentTheme Current Theme
*/
void refresh(LookAndFeel currentLaf, MetalTheme currentTheme)
{
this.laf = currentLaf;
this.theme = currentTheme;
capture = true;
}
示例12: setCurrentMetalTheme
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
/**
* Invoke the correct method to set current metal based theme.
* Supported look and feel are Metal, Plastic and Compiere.
* @param laf Metal based look and feel
* @param theme Metal based theme
*/
static void setCurrentMetalTheme(final MetalLookAndFeel laf, final MetalTheme theme)
{
if (laf instanceof AdempiereLookAndFeel && theme instanceof PlasticTheme)
{
AdempiereLookAndFeel.setCurrentTheme((PlasticTheme)theme);
}
else
{
MetalLookAndFeel.setCurrentTheme(theme);
}
}
示例13: MetalLayoutStyle
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
public MetalLayoutStyle() {
isOcean = false;
try {
Method method = MetalLookAndFeel.class.getMethod("getCurrentTheme", (Class[]) null);
isOcean = ((MetalTheme) method.invoke(null, (Object[]) null)).getName() == "Ocean";
} catch (NoSuchMethodException nsme) {
} catch (IllegalAccessException iae) {
} catch (IllegalArgumentException iae2) {
} catch (InvocationTargetException ite) {
}
}
示例14: createThemesMenuItem
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
/**
* Creates a JRadioButtonMenuItem for the Themes menu
*/
private static JMenuItem createThemesMenuItem(JMenu menu, String label, char mnemonic, MetalTheme theme) {
JRadioButtonMenuItem mi = (JRadioButtonMenuItem) menu.add(new JRadioButtonMenuItem(label));
themesMenuGroup.add(mi);
mi.addActionListener(new ChangeThemeAction(theme));
mi.setMnemonic(mnemonic);
return mi;
}
示例15: getPlasticTheme
import javax.swing.plaf.metal.MetalTheme; //导入依赖的package包/类
/**
* Lazily initializes and returns the PlasticTheme.
*
* @return the current PlasticTheme
*/
public static PlasticTheme getPlasticTheme() {
MetalTheme theme = getCurrentTheme();
if (theme instanceof PlasticTheme) {
return (PlasticTheme) theme;
}
PlasticTheme initialTheme = createMyDefaultTheme();
setPlasticTheme(initialTheme);
return initialTheme;
}