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

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

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

JButton.getBorder介绍

暂无

代码示例

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

JButton button = new JButton("Using Compound Border");
Border lineBorder = BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK);
CompoundBorder border = new CompoundBorder(button.getBorder(), lineBorder);
button.setBorder( border );

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

JButton myButton = new JButton("BUTTON TEXT");
myButton.setBorder(BorderFactory.createCompoundBorder(myButton.getBorder(), BorderFactory.createLineBorder(Color.RED));

代码示例来源:origin: Exslims/MercuryTrade

@Override
public void mouseEntered(MouseEvent e) {
  prevBorder = button.getBorder();
  button.setBorder(BorderFactory.createCompoundBorder(
      BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER),
      BorderFactory.createEmptyBorder(3, 3, 3, 3)));
  button.setCursor(new Cursor(Cursor.HAND_CURSOR));
}

代码示例来源:origin: Exslims/MercuryTrade

@Override
public void mouseEntered(MouseEvent e) {
  this.prevBorder = button.getBorder();
  CompoundBorder compoundBorder = BorderFactory.createCompoundBorder(
      BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER, 1),
      BorderFactory.createLineBorder(button.getBackground(), 3)
  );
  button.setBorder(compoundBorder);
  button.setCursor(new Cursor(Cursor.HAND_CURSOR));
}

代码示例来源:origin: MegaMek/mekhq

public ButtonColumn(JTable table, Action action, int column) {
  this.table = table;
  this.action = action;
  renderButton = new JButton();
  editButton = new JButton();
  editButton.setFocusPainted(false);
  editButton.addActionListener(this);
  originalBorder = editButton.getBorder();
  enabled = true;
  TableColumnModel columnModel = table.getColumnModel();
  columnModel.getColumn(column).setCellRenderer(this);
  columnModel.getColumn(column).setCellEditor(this);
  table.addMouseListener(this);
}

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

public ButtonsInCellRenderer(JTable table, JButton[] buttons, Action[] actions, int column) {
  this.table = table;
  this.actions = actions;
  this.buttons = buttons;
  for (JButton btn : buttons) {
    btn.setFocusPainted(false);
    btn.addActionListener(this);
  }
  border = buttons[0].getBorder();
  setFocusBorder(new LineBorder(Color.BLUE));
  TableColumnModel columnModel = table.getColumnModel();
  columnModel.getColumn(column).setCellRenderer(this);
  columnModel.getColumn(column).setCellEditor(this);
  table.addMouseListener(this);
  panel = new JPanel();
  panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
  panel.add(Box.createHorizontalGlue());
  if (buttons.length > 0)
    panel.add(buttons[0]);
  for (int i = 1; i < buttons.length; i++) {
    panel.add(Box.createHorizontalStrut(BUTTON_SPACER));
    panel.add(buttons[i]);
  }
  panel.add(Box.createHorizontalStrut(BUTTON_SPACER));
}

代码示例来源:origin: com.github.haifengl/smile-plot

/**
 * Create the ButtonCellRenderer to be used as a renderer and editor. The
 * renderer and editor will automatically be installed on the TableColumn of
 * the specified column.
 *
 * @param table the table containing the button renderer/editor
 * @param action the Action to be invoked when the button is invoked
 * @param column the column to which the button renderer/editor is added
 */
public ButtonCellRenderer(JTable table, Action action, int column) {
  this.table = table;
  this.action = action;
  renderButton = new JButton();
  editButton = new JButton();
  editButton.setFocusPainted(false);
  editButton.addActionListener(this);
  originalBorder = editButton.getBorder();
  setFocusBorder(new LineBorder(Color.BLUE));
  TableColumnModel columnModel = table.getColumnModel();
  columnModel.getColumn(column).setCellRenderer(this);
  columnModel.getColumn(column).setCellEditor(this);
  table.addMouseListener(this);
}

代码示例来源:origin: girtel/Net2Plan

/**
 * Create the ButtonColumn to be used as a renderer and editor. The
 * renderer and editor will automatically be installed on the TableColumn
 * of the specified column.
 *
 * @param table  the table containing the button renderer/editor
 * @param action the Action to be invoked when the button is invoked
 * @param column the column to which the button renderer/editor is added
 * @since 0.2.3
 */
public ButtonColumn(JTable table, Action action, int column) {
  this.table = table;
  this.action = action;
  renderButton = new JButton();
  editButton = new JButton();
  editButton.setFocusPainted(false);
  editButton.addActionListener(this);
  originalBorder = editButton.getBorder();
  setFocusBorder(new LineBorder(Color.BLUE));
  TableColumnModel columnModel = table.getColumnModel();
  columnModel.getColumn(column).setCellRenderer(this);
  columnModel.getColumn(column).setCellEditor(this);
  table.addMouseListener(this);
}

代码示例来源:origin: dschanoeh/Kayak

/**
 *  Create the ButtonColumn to be used as a renderer and editor. The
 *  renderer and editor will automatically be installed on the TableColumn
 *  of the specified column.
 *
 *  @param table the table containing the button renderer/editor
 *  @param action the Action to be invoked when the button is invoked
 *  @param column the column to which the button renderer/editor is added
 */
public ButtonColumn(JTable table, Action action, int column) {
  this.table = table;
  this.action = action;
  renderButton = new JButton();
  editButton = new JButton();
  editButton.setFocusPainted(false);
  editButton.addActionListener(this);
  originalBorder = editButton.getBorder();
  setFocusBorder(new LineBorder(Color.BLUE));
  TableColumnModel columnModel = table.getColumnModel();
  columnModel.getColumn(column).setCellRenderer(this);
  columnModel.getColumn(column).setCellEditor(this);
  table.addMouseListener(this);
}

代码示例来源:origin: sebbrudzinski/Open-LaTeX-Studio

/**
 * Create the ButtonColumn to be used as a renderer and editor. The renderer
 * and editor will automatically be installed on the TableColumn of the
 * specified column.
 *
 * @param table the table containing the button renderer/editor
 * @param action the Action to be invoked when the button is invoked
 * @param column the column to which the button renderer/editor is added
 */
public ButtonColumn(JTable table, Action action, int column) {
  this.table = table;
  this.action = action;
  renderButton = new JButton();
  editButton = new JButton();
  editButton.setFocusPainted(false);
  editButton.addActionListener(this);
  originalBorder = editButton.getBorder();
  setFocusBorder(new LineBorder(Color.BLUE));
  TableColumnModel columnModel = table.getColumnModel();
  columnModel.getColumn(column).setCellRenderer(this);
  columnModel.getColumn(column).setCellEditor(this);
  table.addMouseListener(this);
}

代码示例来源:origin: cmu-phil/tetrad

/**
 * Create the ButtonColumn to be used as a renderer and editor. The renderer
 * and editor will automatically be installed on the TableColumn of the
 * specified column.
 *
 * @param table
 *            the table containing the button renderer/editor
 * @param action
 *            the Action to be invoked when the button is invoked
 * @param column
 *            the column to which the button renderer/editor is added
 */
public ButtonColumn(JTable table, Action action, int column) {
this.table = table;
this.action = action;
renderButton = new JButton();
editButton = new JButton();
editButton.setFocusPainted(false);
editButton.addActionListener(this);
originalBorder = editButton.getBorder();
setFocusBorder(new LineBorder(Color.BLUE));
TableColumnModel columnModel = table.getColumnModel();
columnModel.getColumn(column).setCellRenderer(this);
columnModel.getColumn(column).setCellEditor(this);
table.addMouseListener(this);
}

代码示例来源:origin: org.databene/databene-commons

public static void equalizeButtonSizes(Graphics g, JButton... buttons) {
  String[] labels = BeanUtil.extractProperties(buttons, "text", String.class);
  // Get the largest width and height
  Dimension maxSize = new Dimension(0, 0);
  Rectangle2D textBounds = null;
  JButton button0 = buttons[0];
  FontMetrics metrics = button0.getFontMetrics(button0.getFont());
  for (int i = 0; i < labels.length; ++i) {
    textBounds = metrics.getStringBounds(labels[i], g);
    maxSize.width = Math.max(maxSize.width, (int) textBounds.getWidth());
    maxSize.height = Math.max(maxSize.height, (int) textBounds.getHeight());
  }
  Insets insets = button0.getBorder().getBorderInsets(button0);
  maxSize.width += insets.left + insets.right;
  maxSize.height += insets.top + insets.bottom;
  // reset preferred and maximum size since BoxLayout takes both into account
  for (JButton button : buttons) {
    button.setPreferredSize((Dimension) maxSize.clone());
    button.setMaximumSize((Dimension) maxSize.clone());
  }
}

代码示例来源:origin: sing-group/GC4S

this.colorList.setCellRenderer(new ColorListCellRenderer() {
  private static final long serialVersionUID = 1L;
  private final Border defaultBorder = new JButton().getBorder();
  @Override
  public Component getListCellRendererComponent(

相关文章

JButton类方法