javax.swing.JButton.setUI()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(217)

本文整理了Java中javax.swing.JButton.setUI()方法的一些代码示例,展示了JButton.setUI()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.setUI()方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:setUI

JButton.setUI介绍

暂无

代码示例

代码示例来源:origin: skylot/jadx

  1. button.setRolloverEnabled(true);
  2. button.setOpaque(false);
  3. button.setUI(new BasicButtonUI());
  4. button.setContentAreaFilled(false);
  5. button.setFocusable(false);

代码示例来源:origin: tomighty/tomighty

  1. public JButton create(Action[] actions) {
  2. final JPopupMenu menu = popupMenuFactory.create(actions);
  3. final JButton button = new JButton();
  4. button.setUI(arrowButtonUI);
  5. button.addActionListener(new ActionListener() {
  6. @Override
  7. public void actionPerformed(ActionEvent e) {
  8. menu.show(button, 0, button.getHeight());
  9. }
  10. });
  11. return button;
  12. }

代码示例来源:origin: tomighty/tomighty

  1. private Component createButtons() {
  2. Action[] actions = primaryActions();
  3. JPanel buttons = createPanel(new GridLayout(1, actions.length, 3, 0));
  4. for(Action action : actions) {
  5. injector.injectMembers(action);
  6. JButton button = new JButton(action);
  7. button.setOpaque(false);
  8. button.setUI(SexyButtonUI.INSTANCE);
  9. buttons.add(button);
  10. }
  11. return buttons;
  12. }

代码示例来源:origin: tomighty/tomighty

  1. private JButton createButton() {
  2. JButton button = new JButton();
  3. button.setModel(buttonModel);
  4. button.setUI(new GaugeButtonUI());
  5. button.setOpaque(false);
  6. button.setPreferredSize(BUTTON_SIZE);
  7. button.addActionListener(new ActionListener() {
  8. @Override
  9. public void actionPerformed(ActionEvent e) {
  10. buttonModel.turnNextLightOn();
  11. turnAllLightsOffIfAllAreOn();
  12. }
  13. });
  14. return button;
  15. }

代码示例来源:origin: stackoverflow.com

  1. public static JButton createStyledButton(String text) {
  2. JButton button = new JButton(text);
  3. button.setUI(STYLE_UI);
  4. return button;
  5. }

代码示例来源:origin: stackoverflow.com

  1. public static JButton createStyledButton(String text) {
  2. JButton button = new JButton(text);
  3. button.setUI(STYLE_UI);
  4. return button;
  5. }

代码示例来源:origin: stackoverflow.com

  1. JButton btn = new JButton("codelife.de");
  2. btn.setUI(new CustomizedButtonUI(Color.RED, Color.ORANGE, Color.GREEN));

代码示例来源:origin: com.fifesoft.rtext/fife.common

  1. @Override
  2. public void setUI(ButtonUI ui) {
  3. super.setUI(new BreadcrumbBarButtonUI());
  4. }

代码示例来源:origin: violetumleditor/violetumleditor

  1. /**
  2. * Adds a button to the main panel
  3. *
  4. * @param aButton
  5. */
  6. private void addButton(JButton aButton)
  7. {
  8. aButton.setUI(new IconButtonUI());
  9. getPanel().add(aButton);
  10. }

代码示例来源:origin: stackoverflow.com

  1. public static void main (String[] args) {
  2. JFrame f = new JFrame("Button UI Test");
  3. f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  4. JPanel p = new JPanel();
  5. p.setBackground(Color.white);
  6. f.setContentPane(p);
  7. p.setLayout(new FlowLayout(5, 5));
  8. p.setBorder(new EmptyBorder(10, 10, 10, 10));
  9. for (int i = 1; i <= 5; i++) {
  10. final JButton button = new JButton("Button #" + i);
  11. button.setFont(new Font("Calibri", Font.PLAIN, 14));
  12. button.setBackground(new Color(0x2dce98));
  13. button.setForeground(Color.white);
  14. // customize the button with your own look
  15. button.setUI(new StyledButtonUI());
  16. p.add(button);
  17. }
  18. f.pack();
  19. f.setLocation(500, 500);
  20. f.setVisible(true);
  21. }

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

  1. public Component create(Context context) {
  2. JButton button = new ToolWindowActiveButton();
  3. button.setUI((ButtonUI) BasicButtonUI.createUI(button));
  4. return button;
  5. }

代码示例来源:origin: protegeproject/protege

  1. /**
  2. * Adds an action to the view header.
  3. * @param action The action to be added.
  4. */
  5. public void addAction(@Nonnull Action action) {
  6. String name = (String) action.getValue(Action.NAME);
  7. action.putValue(Action.NAME, "");
  8. action.putValue(Action.SHORT_DESCRIPTION, name);
  9. JButton button = new JButton(action) {
  10. public void updateUI() {
  11. }
  12. };
  13. button.setFocusable(false);
  14. toolBar.add(button);
  15. Icon icon = (Icon) action.getValue(Action.SMALL_ICON);
  16. if (icon != null) {
  17. button.setPreferredSize(new Dimension(icon.getIconWidth() + 2, icon.getIconHeight()));
  18. button.setOpaque(false);
  19. button.setUI(new ViewButtonUI());
  20. button.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));
  21. }
  22. }
  23. }

代码示例来源:origin: cytoscape/application

  1. private void setDefaultPanel(final Image defImage, boolean repaint) {
  2. if (defImage == null)
  3. return;
  4. defaultAppearencePanel.removeAll();
  5. final JButton defaultImageButton = new JButton();
  6. defaultImageButton.setUI(new BlueishButtonUI());
  7. defaultImageButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  8. defaultImageButton.setIcon(new ImageIcon(defImage));
  9. defaultAppearencePanel.add(defaultImageButton, BorderLayout.CENTER);
  10. defaultImageButton.addMouseListener(new DefaultMouseListener());
  11. if ( repaint )
  12. Cytoscape.getDesktop().repaint();
  13. }

代码示例来源:origin: datacleaner/DataCleaner

  1. public static JButton createSmallButton(final String text, final Icon icon) {
  2. final JButton b = new JButton(icon);
  3. if (text != null) {
  4. b.setText(text);
  5. b.setFont(WidgetUtils.FONT_SMALL);
  6. }
  7. b.setMargin(new Insets(0, 0, 0, 0));
  8. b.setUI(new MetalButtonUI());
  9. b.setBackground(WidgetUtils.COLOR_WELL_BACKGROUND);
  10. final MatteBorder outerBorder = new MatteBorder(1, 1, 1, 1, WidgetUtils.BG_COLOR_LESS_BRIGHT);
  11. b.setBorder(new CompoundBorder(outerBorder, new EmptyBorder(2, 4, 2, 4)));
  12. b.setFocusPainted(false);
  13. return b;
  14. }

代码示例来源:origin: edu.stanford.protege/org.protege.editor.core.application

  1. /**
  2. * Adds an action to the view header.
  3. * @param action The action to be added.
  4. */
  5. public void addAction(Action action) {
  6. String name = (String) action.getValue(AbstractAction.NAME);
  7. action.putValue(AbstractAction.NAME, "");
  8. action.putValue(AbstractAction.SHORT_DESCRIPTION, name);
  9. JButton button = new JButton(action) {
  10. /**
  11. *
  12. */
  13. private static final long serialVersionUID = -5577350824168578334L;
  14. public void updateUI() {
  15. // super.updateUI();
  16. }
  17. };
  18. button.setFocusable(false);
  19. toolBar.add(button);
  20. Icon icon = (Icon) action.getValue(AbstractAction.SMALL_ICON);
  21. if (icon != null) {
  22. button.setPreferredSize(new Dimension(icon.getIconWidth() + 2, icon.getIconHeight()));
  23. button.setOpaque(false);
  24. button.setUI(new ViewButtonUI());
  25. button.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));
  26. }
  27. }

代码示例来源:origin: org.protege/protege-editor-core-application

  1. /**
  2. * Adds an action to the view header.
  3. * @param action The action to be added.
  4. */
  5. public void addAction(Action action) {
  6. String name = (String) action.getValue(AbstractAction.NAME);
  7. action.putValue(AbstractAction.NAME, "");
  8. action.putValue(AbstractAction.SHORT_DESCRIPTION, name);
  9. JButton button = new JButton(action) {
  10. /**
  11. *
  12. */
  13. private static final long serialVersionUID = -5577350824168578334L;
  14. public void updateUI() {
  15. // super.updateUI();
  16. }
  17. };
  18. button.setFocusable(false);
  19. toolBar.add(button);
  20. Icon icon = (Icon) action.getValue(AbstractAction.SMALL_ICON);
  21. if (icon != null) {
  22. button.setPreferredSize(new Dimension(icon.getIconWidth() + 2, icon.getIconHeight()));
  23. button.setOpaque(false);
  24. button.setUI(new ViewButtonUI());
  25. button.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));
  26. }
  27. }

代码示例来源:origin: violetumleditor/violetumleditor

  1. @Override
  2. public void installUI(JComponent c)
  3. {
  4. c.removeAll();
  5. c.setBackground(ThemeManager.getInstance().getTheme().getSidebarElementBackgroundColor());
  6. this.editorToolsPanel.getZoomInButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  7. this.editorToolsPanel.getZoomOutButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  8. this.editorToolsPanel.getDeleteButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  9. this.editorToolsPanel.getUndoButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  10. this.editorToolsPanel.getRedoButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  11. this.editorToolsPanel.getCutButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  12. this.editorToolsPanel.getCopyButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  13. this.editorToolsPanel.getPasteButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  14. c.setLayout(new FlowLayout(FlowLayout.CENTER));
  15. c.add(getToolsPanel());
  16. }

代码示例来源:origin: org.cytoscape/vizmap-gui-impl

  1. protected JButton getDefaultBtn() {
  2. if (defaultBtn == null) {
  3. defaultBtn = new VizMapperButton();
  4. defaultBtn.setUI(new VPButtonUI(VPButtonUI.SOUTH));
  5. defaultBtn.setDisabledIcon(disabledBtnIcon);
  6. updateDefaultButton();
  7. }
  8. return defaultBtn;
  9. }

代码示例来源:origin: org.cytoscape/vizmap-gui-impl

  1. protected JButton getBypassBtn() {
  2. if (bypassBtn == null) {
  3. bypassBtn = new VizMapperButton();
  4. bypassBtn.setIcon(getIcon(model.getLockedValue(), VALUE_ICON_WIDTH, VALUE_ICON_HEIGHT));
  5. bypassBtn.setUI(new VPButtonUI(VPButtonUI.SOUTH));
  6. bypassBtn.setDisabledIcon(disabledBtnIcon);
  7. updateBypassButton();
  8. }
  9. return bypassBtn;
  10. }

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

  1. public void setUI(ButtonUI ui) {
  2. UIManager.put("Button.textShiftOffset", 1);
  3. super.setUI(new BasicButtonUI() {
  4. protected void paintButtonPressed(Graphics g, AbstractButton b) {
  5. setTextShiftOffset();
  6. }
  7. });
  8. setRolloverEnabled(true);
  9. setOpaque(false);
  10. setFocusPainted(false);
  11. setFocusable(false);
  12. setBorder(null);
  13. setBorderPainted(false);
  14. }
  15. }

相关文章

JButton类方法