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

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

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

JButton.setUI介绍

暂无

代码示例

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

button.setRolloverEnabled(true);
button.setOpaque(false);
button.setUI(new BasicButtonUI());
button.setContentAreaFilled(false);
button.setFocusable(false);

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

public JButton create(Action[] actions) {
  final JPopupMenu menu = popupMenuFactory.create(actions);
  final JButton button = new JButton();
  button.setUI(arrowButtonUI);
  button.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      menu.show(button, 0, button.getHeight());
    }
  });
  return button;
}

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

private Component createButtons() {
  Action[] actions = primaryActions();
  JPanel buttons = createPanel(new GridLayout(1, actions.length, 3, 0));
  for(Action action : actions) {
    injector.injectMembers(action);
    JButton button = new JButton(action);
    button.setOpaque(false);
    button.setUI(SexyButtonUI.INSTANCE);
    buttons.add(button);
  }
  return buttons;
}

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

private JButton createButton() {
  JButton button = new JButton();
  button.setModel(buttonModel);
  button.setUI(new GaugeButtonUI());
  button.setOpaque(false);
  button.setPreferredSize(BUTTON_SIZE);
  button.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      buttonModel.turnNextLightOn();
      turnAllLightsOffIfAllAreOn();
    }
  });
  return button;
}

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

public static JButton createStyledButton(String text) {
  JButton button = new JButton(text);
  button.setUI(STYLE_UI);
  return button;
}

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

public static JButton createStyledButton(String text) {
  JButton button = new JButton(text);
  button.setUI(STYLE_UI);
  return button;
}

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

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

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

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

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

/**
 * Adds a button to the main panel
 * 
 * @param aButton
 */
private void addButton(JButton aButton)
{
  aButton.setUI(new IconButtonUI());
  getPanel().add(aButton);
}

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

public static void main (String[] args) {
  JFrame f = new JFrame("Button UI Test");
  f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  JPanel p = new JPanel();
  p.setBackground(Color.white);
  f.setContentPane(p);
  p.setLayout(new FlowLayout(5, 5));
  p.setBorder(new EmptyBorder(10, 10, 10, 10));

  for (int i = 1; i <= 5; i++) {
    final JButton button = new JButton("Button #" + i);
    button.setFont(new Font("Calibri", Font.PLAIN, 14));
    button.setBackground(new Color(0x2dce98));
    button.setForeground(Color.white);
    // customize the button with your own look
    button.setUI(new StyledButtonUI());
    p.add(button);
  }

  f.pack();
  f.setLocation(500, 500);
  f.setVisible(true);
}

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

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

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

/**
   * Adds an action to the view header.
   * @param action The action to be added.
   */
  public void addAction(@Nonnull Action action) {
    String name = (String) action.getValue(Action.NAME);
    action.putValue(Action.NAME, "");
    action.putValue(Action.SHORT_DESCRIPTION, name);
    JButton button = new JButton(action) {
      public void updateUI() {
      }
    };
    button.setFocusable(false);
    toolBar.add(button);
    Icon icon = (Icon) action.getValue(Action.SMALL_ICON);
    if (icon != null) {
      button.setPreferredSize(new Dimension(icon.getIconWidth() + 2, icon.getIconHeight()));
      button.setOpaque(false);
      button.setUI(new ViewButtonUI());
      button.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));
    }
  }
}

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

private void setDefaultPanel(final Image defImage, boolean repaint) {
  if (defImage == null)
    return;
  defaultAppearencePanel.removeAll();
  final JButton defaultImageButton = new JButton();
  defaultImageButton.setUI(new BlueishButtonUI());
  defaultImageButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  defaultImageButton.setIcon(new ImageIcon(defImage));
  defaultAppearencePanel.add(defaultImageButton, BorderLayout.CENTER);
  defaultImageButton.addMouseListener(new DefaultMouseListener());
  if ( repaint )
    Cytoscape.getDesktop().repaint();
}

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

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

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

/**
   * Adds an action to the view header.
   * @param action The action to be added.
   */
  public void addAction(Action action) {
    String name = (String) action.getValue(AbstractAction.NAME);
    action.putValue(AbstractAction.NAME, "");
    action.putValue(AbstractAction.SHORT_DESCRIPTION, name);
    JButton button = new JButton(action) {
      /**
       * 
       */
      private static final long serialVersionUID = -5577350824168578334L;

      public void updateUI() {
//                super.updateUI();
      }
    };
    button.setFocusable(false);
    toolBar.add(button);
    Icon icon = (Icon) action.getValue(AbstractAction.SMALL_ICON);
    if (icon != null) {
      button.setPreferredSize(new Dimension(icon.getIconWidth() + 2, icon.getIconHeight()));
      button.setOpaque(false);
      button.setUI(new ViewButtonUI());
      button.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));
    }
  }

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

/**
   * Adds an action to the view header.
   * @param action The action to be added.
   */
  public void addAction(Action action) {
    String name = (String) action.getValue(AbstractAction.NAME);
    action.putValue(AbstractAction.NAME, "");
    action.putValue(AbstractAction.SHORT_DESCRIPTION, name);
    JButton button = new JButton(action) {
      /**
       * 
       */
      private static final long serialVersionUID = -5577350824168578334L;

      public void updateUI() {
//                super.updateUI();
      }
    };
    button.setFocusable(false);
    toolBar.add(button);
    Icon icon = (Icon) action.getValue(AbstractAction.SMALL_ICON);
    if (icon != null) {
      button.setPreferredSize(new Dimension(icon.getIconWidth() + 2, icon.getIconHeight()));
      button.setOpaque(false);
      button.setUI(new ViewButtonUI());
      button.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1));
    }
  }

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

@Override
public void installUI(JComponent c)
{
  c.removeAll();
  c.setBackground(ThemeManager.getInstance().getTheme().getSidebarElementBackgroundColor());
  this.editorToolsPanel.getZoomInButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  this.editorToolsPanel.getZoomOutButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  this.editorToolsPanel.getDeleteButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  this.editorToolsPanel.getUndoButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  this.editorToolsPanel.getRedoButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  this.editorToolsPanel.getCutButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  this.editorToolsPanel.getCopyButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  this.editorToolsPanel.getPasteButton().setUI(new IconButtonUI(FULLSIZE_SCALING_FACTOR));
  c.setLayout(new FlowLayout(FlowLayout.CENTER));
  c.add(getToolsPanel());
}

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

protected JButton getDefaultBtn() {
  if (defaultBtn == null) {
    defaultBtn = new VizMapperButton();
    defaultBtn.setUI(new VPButtonUI(VPButtonUI.SOUTH));
    defaultBtn.setDisabledIcon(disabledBtnIcon);
    updateDefaultButton();
  }
  
  return defaultBtn;
}

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

protected JButton getBypassBtn() {
  if (bypassBtn == null) {
    bypassBtn = new VizMapperButton();
    bypassBtn.setIcon(getIcon(model.getLockedValue(), VALUE_ICON_WIDTH, VALUE_ICON_HEIGHT));
    bypassBtn.setUI(new VPButtonUI(VPButtonUI.SOUTH));
    bypassBtn.setDisabledIcon(disabledBtnIcon);
    updateBypassButton();
  }
  
  return bypassBtn;
}

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

public void setUI(ButtonUI ui) {
    UIManager.put("Button.textShiftOffset", 1);
    super.setUI(new BasicButtonUI() {
      protected void paintButtonPressed(Graphics g, AbstractButton b) {
        setTextShiftOffset();
      }
    });

    setRolloverEnabled(true);
    setOpaque(false);
    setFocusPainted(false);
    setFocusable(false);
    setBorder(null);
    setBorderPainted(false);
  }
}

相关文章

微信公众号

最新文章

更多

JButton类方法