当前位置: 首页>>代码示例>>Java>>正文


Java UIManager.getLookAndFeel方法代码示例

本文整理汇总了Java中javax.swing.UIManager.getLookAndFeel方法的典型用法代码示例。如果您正苦于以下问题:Java UIManager.getLookAndFeel方法的具体用法?Java UIManager.getLookAndFeel怎么用?Java UIManager.getLookAndFeel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.UIManager的用法示例。


在下文中一共展示了UIManager.getLookAndFeel方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyNbSkin

import javax.swing.UIManager; //导入方法依赖的package包/类
static void applyNbSkin() {
    LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
    String name = lookAndFeel.getName();
    switch (name) {
        case "Mac OS X":
            name = "mac";
            break;
        case "Metal":
            name = "metal";
            break;
        case "GTK look and feel":
            name = "gtk";
            break;
        case "Nimbus":
            name = "nimbus";
            break;
        case "Windows":
            name = "win";
            break;
        case "Darcula":
            name = "darcula";
            break;
    }
    final String resource = "nbres:/org/netbeans/modules/htmlui/css/wizard-" + name + ".css";
    loadCss(resource);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:NbBrowsers.java

示例2: getLFHeightAdjustment

import javax.swing.UIManager; //导入方法依赖的package包/类
private static int getLFHeightAdjustment() {
    LookAndFeel lf = UIManager.getLookAndFeel();
    String lfID = lf.getID();
    logger.fine("createSingleLineEditor(): current L&F = '"+lfID+"'");
    if ("Metal".equals(lfID)) {
        return 0;
    }
    if ("GTK".equals(lfID)) {
        return 2;
    }
    if ("Motif".equals(lfID)) {
        return 3;
    }
    if ("Nimbus".equals(lfID)) {
        return 0;
    }
    if ("Aqua".equals(lfID)) {
        return -2;
    }
    return 0;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:Utilities.java

示例3: paintComponent

import javax.swing.UIManager; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void paintComponent(Graphics graphics) {
	// Surchargée pour dessiner le fond avec gradient
	final LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
	final String lafName = lookAndFeel != null ? lookAndFeel.getName() : null;
	if ("Substance".equals(lafName)) {
		super.paintComponent(graphics); // le gradient fonctionne mal en substance ?
	}

	final Color startColor = getBackground();
	final Color endColor = GRADIENT_COLOR;
	final int w = getWidth();
	final int h = getHeight();

	// l'image du gradient pourrait être mise en cache, mais ce n'est pas grave
	final Paint paint = new GradientPaint(0, h / 2f, startColor, 1, h, endColor, false);
	final Graphics2D graphix = (Graphics2D) graphics.create();
	graphix.setPaint(paint);
	graphix.fillRect(0, 0, w, h);
	graphix.dispose();
}
 
开发者ID:evernat,项目名称:dead-code-detector,代码行数:23,代码来源:DeadCodeDetectorUI.java

示例4: getLAF

import javax.swing.UIManager; //导入方法依赖的package包/类
public static final LookAndFeelType getLAF() {
    if(lookAndFeelType==null) {
        try {
            initializeLookAndFeel();
        } catch (InitializationException e) {
            LogManager.log(e);
        }
        lookAndFeelType = LookAndFeelType.DEFAULT;

        if (!uiUnavailable && UiMode.getCurrentUiMode() == UiMode.SWING) {
            LookAndFeel laf = UIManager.getLookAndFeel();
            if (laf != null) {
                String id = laf.getID();
                for (LookAndFeelType type : LookAndFeelType.values()) {
                    if (id.equals(LookAndFeelType.WINDOWS_XP.getId()) ||
                            id.equals(LookAndFeelType.WINDOWS_CLASSIC.getId())) {
                        final Object object = Toolkit.getDefaultToolkit().
                                getDesktopProperty(WINDOWS_XP_THEME_MARKER_PROPERTY);
                        boolean xpThemeActive = false;
                        if (object != null) {
                            xpThemeActive = (Boolean) object;
                        }
                        lookAndFeelType = (xpThemeActive) ? LookAndFeelType.WINDOWS_XP : LookAndFeelType.WINDOWS_CLASSIC;
                        break;
                    } else if (id.equals(type.getId())) {
                        lookAndFeelType = type;
                        break;
                    }
                }
            }
        }
    }
    return lookAndFeelType;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:UiUtils.java

示例5: getSharedInstance

import javax.swing.UIManager; //导入方法依赖的package包/类
/**
 * Factory methods for obtaining the current <code>LayoutStyle</code>
 * object appropriate for the current look and feel.
 * 
 * @return the current LayoutStyle instance
 */
public static LayoutStyle getSharedInstance() {
    Object layoutImpl = UIManager.get("LayoutStyle.instance");
    if (layoutImpl != null && (layoutImpl instanceof LayoutStyle)) {
        return (LayoutStyle)layoutImpl;
    }
    LookAndFeel currentLAF = UIManager.getLookAndFeel();
    if (layoutStyle == null || currentLAF != laf) {
        laf = currentLAF;
        String lafID= laf.getID();
        if (USE_CORE_LAYOUT_STYLE) {
            layoutStyle = new SwingLayoutStyle();
        } else if ("Metal" == lafID) {
            layoutStyle = new MetalLayoutStyle();
        }
        else if ("Windows" == lafID) {
            layoutStyle = new WindowsLayoutStyle();
        }
        else if ("GTK" == lafID) {
            layoutStyle = new GnomeLayoutStyle();
        }
        else if ("Aqua" == lafID) {
            layoutStyle = new AquaLayoutStyle();
        } else {
            layoutStyle = new LayoutStyle();
        }
    }
    return layoutStyle;
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:35,代码来源:LayoutStyle.java

示例6: setIndeterminate

import javax.swing.UIManager; //导入方法依赖的package包/类
@Override
public void setIndeterminate(boolean indeterminate) {
  // workaround for bug in some versions of Aqua L&F that prevents GATE
  // from exiting if indeterminate progress bars are used
  if(Gate.runningOnMac() && (UIManager.getLookAndFeel() == null
      || UIManager.getLookAndFeel().getClass().getName().equals(
        UIManager.getSystemLookAndFeelClassName()))) {
    return;
  } else {
    super.setIndeterminate(indeterminate);
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:13,代码来源:ProgressPanel.java

示例7: installAudioActionMap

import javax.swing.UIManager; //导入方法依赖的package包/类
/**
 * Sets the parent of the passed in ActionMap to be the audio action
 * map.
 */
static void installAudioActionMap(ActionMap map) {
    LookAndFeel laf = UIManager.getLookAndFeel();
    if (laf instanceof BasicLookAndFeel) {
        map.setParent(((BasicLookAndFeel)laf).getAudioActionMap());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:BasicLookAndFeel.java

示例8: playSound

import javax.swing.UIManager; //导入方法依赖的package包/类
/**
 * Helper method to play a named sound.
 *
 * @param c JComponent to play the sound for.
 * @param actionKey Key for the sound.
 */
static void playSound(JComponent c, Object actionKey) {
    LookAndFeel laf = UIManager.getLookAndFeel();
    if (laf instanceof BasicLookAndFeel) {
        ActionMap map = c.getActionMap();
        if (map != null) {
            Action audioAction = map.get(actionKey);
            if (audioAction != null) {
                // pass off firing the Action to a utility method
                ((BasicLookAndFeel)laf).playSound(audioAction);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:BasicLookAndFeel.java

示例9: setup

import javax.swing.UIManager; //导入方法依赖的package包/类
private void setup()
{
	bullets = new ImageIcon(ManagementDialog.class.getResource("/icons/menuitem.gif"));

	currentLaF = UIManager.getLookAndFeel();
	flatterLaF = new FlatterLookAndFeel();

	JImage header = new JImage(ManagementDialog.class.getResource("/icons/header.gif"));
	Dimension size1 = new Dimension(450, 70);
	header.setSize(size1);
	header.setMinimumSize(size1);
	header.setPreferredSize(size1);
	header.setMaximumSize(size1);

	JImage footer = new JImage(ManagementDialog.class.getResource("/icons/footer.gif"));
	Dimension size2 = new Dimension(450, 6);
	footer.setSize(size2);
	footer.setMinimumSize(size2);
	footer.setPreferredSize(size2);
	footer.setMaximumSize(size2);

	toolsPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 5, 1, false, false));
	right = new JPanel(new GridLayout(1, 1));

	ImageIcon icon = new ImageIcon(ManagementDialog.class.getResource(EXIT_ICON));
	exitButton = new JHoverButton(CurrentLocale.get("com.tle.admin.gui.managementdialog.exit"), icon);
	setupButton(exitButton);

	JPanel south = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
	south.add(exitButton);

	JPanel left = new JPanel(new BorderLayout());
	left.add(toolsPanel, BorderLayout.CENTER);
	left.add(south, BorderLayout.SOUTH);

	final int[] rows = {TableLayout.FILL,};
	final int[] cols = {175, TableLayout.FILL,};

	JPanel centre = new JPanel(new TableLayout(rows, cols, 5, 5));
	centre.add(left, new Rectangle(0, 0, 1, 1));
	centre.add(right, new Rectangle(1, 0, 1, 1));

	JPanel all = new JPanel(new BorderLayout());
	all.setBackground(Color.white);
	all.add(header, BorderLayout.NORTH);
	all.add(centre, BorderLayout.CENTER);
	all.add(footer, BorderLayout.SOUTH);

	applyFlatterLaF(all);

	setTitle(CurrentLocale.get("com.tle.admin.gui.managementdialog.title",
		Driver.instance().getVersion().getFull(), Driver.instance().getInstitutionName()));
	setIconImage(new ImageIcon(ManagementDialog.class.getResource("/icons/windowicon.gif")).getImage());
	setContentPane(all);
	setResizable(false);
	setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
	addWindowListener(this);
	setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

	ComponentHelper.centreOnScreen(this);
}
 
开发者ID:equella,项目名称:Equella,代码行数:62,代码来源:ManagementDialog.java

示例10: getActionDescriptors

import javax.swing.UIManager; //导入方法依赖的package包/类
@Override
public ActionDescriptor[] getActionDescriptors() {
    LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
    ActionDescriptor[] res = new ActionDescriptor[infos.length];
    final LookAndFeel laf = UIManager.getLookAndFeel();
    for (int i = 0; i < infos.length; i++) {
        final LookAndFeelInfo info = infos[i];
        ActionDescriptor ad = new ActionDescriptor();

        ad.setActionLevel(ActionLevel.GLOBAL);
        ad.setButtonGroup("LookAndFeel");
        ad.setMenu("Windows/LookAndFeel");
        ad.setSelective(true);

        AbstractAction action = new AbstractAction() {
            /**
             *
             */
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                Options.setString("LookAndFeel", info.getClassName());
                System.setProperty("AnywayExit", Boolean.TRUE.toString());
                JOptionPane
                        .showMessageDialog(
                                framework.getMainFrame(),
                                GlobalResourcesManager
                                        .getString("LookAndFeelWillApplyAfterProgramReboot"));
            }
        };

        action.putValue(Action.SELECTED_KEY, (info.getClassName()
                .equals(laf.getClass().getName())));
        action.putValue(Action.ACTION_COMMAND_KEY, info.getName());
        ad.setAction(action);

        res[i] = ad;
    }
    return res;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:42,代码来源:LookAndFeelPlugin.java

示例11: getTreeCellRendererComponent

import javax.swing.UIManager; //导入方法依赖的package包/类
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:71,代码来源:DefaultTreeCellRenderer.java

示例12: runTestCase

import javax.swing.UIManager; //导入方法依赖的package包/类
private static void runTestCase() throws Exception {
    Point centerPoint;
    centerPoint = Util.getCenterPoint(table);
    LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
    robot.mouseMove(centerPoint.x, centerPoint.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            table.clearSelection();
            if (table.isEditing() || table.isCellSelected(0, 0)) {
                // assumption is bad, bail
                frame.dispose();
                throw new AssertionError("Failed assumption: assumed no"
                        + "editing and no selection.");
            }
        }
    });
    robot.waitForIdle();
    int fetchKeyCode;
    keyTap(fetchKeyCode = isMac(lookAndFeel)
            ? KeyEvent.VK_ENTER : KeyEvent.VK_SPACE);
    final int keyCode = fetchKeyCode;
    robot.waitForIdle();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            if (!table.isCellSelected(0, 0)) {
                frame.dispose();
                throw new RuntimeException(((keyCode == KeyEvent.VK_ENTER)
                        ? "Enter" : "Space")
                        + " should select cell");
            }
        }
    });
    robot.waitForIdle();
    keyTap(KeyEvent.VK_SPACE);
    robot.waitForIdle();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            if (!table.isEditing()) {
                frame.dispose();
                throw new RuntimeException("Space should start editing");
            }
            table.getCellEditor().cancelCellEditing();
            table.clearSelection();
            if (table.isEditing() || table.isCellSelected(0, 0)) {
                // assumption is bad, bail
                frame.dispose();
                throw new AssertionError("Failed assumption: assumed no "
                        + "editing and no selection.");
            }
        }
    });
    robot.waitForIdle();
    // hitting a letter key will start editing
    keyTap(KeyEvent.VK_A);
    keyTap(KeyEvent.VK_SPACE);
    keyTap(KeyEvent.VK_A);
    robot.waitForIdle();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            if (table.isCellSelected(0, 0)) {
                frame.dispose();
                throw new RuntimeException("Space should not select when "
                        + "already editing.");
            }
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:74,代码来源:SelectEditTableCell.java


注:本文中的javax.swing.UIManager.getLookAndFeel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。