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

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

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

JButton.getBorder介绍

暂无

代码示例

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

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

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

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

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

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

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

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

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

  1. public ButtonColumn(JTable table, Action action, int column) {
  2. this.table = table;
  3. this.action = action;
  4. renderButton = new JButton();
  5. editButton = new JButton();
  6. editButton.setFocusPainted(false);
  7. editButton.addActionListener(this);
  8. originalBorder = editButton.getBorder();
  9. enabled = true;
  10. TableColumnModel columnModel = table.getColumnModel();
  11. columnModel.getColumn(column).setCellRenderer(this);
  12. columnModel.getColumn(column).setCellEditor(this);
  13. table.addMouseListener(this);
  14. }

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

  1. public ButtonsInCellRenderer(JTable table, JButton[] buttons, Action[] actions, int column) {
  2. this.table = table;
  3. this.actions = actions;
  4. this.buttons = buttons;
  5. for (JButton btn : buttons) {
  6. btn.setFocusPainted(false);
  7. btn.addActionListener(this);
  8. }
  9. border = buttons[0].getBorder();
  10. setFocusBorder(new LineBorder(Color.BLUE));
  11. TableColumnModel columnModel = table.getColumnModel();
  12. columnModel.getColumn(column).setCellRenderer(this);
  13. columnModel.getColumn(column).setCellEditor(this);
  14. table.addMouseListener(this);
  15. panel = new JPanel();
  16. panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
  17. panel.add(Box.createHorizontalGlue());
  18. if (buttons.length > 0)
  19. panel.add(buttons[0]);
  20. for (int i = 1; i < buttons.length; i++) {
  21. panel.add(Box.createHorizontalStrut(BUTTON_SPACER));
  22. panel.add(buttons[i]);
  23. }
  24. panel.add(Box.createHorizontalStrut(BUTTON_SPACER));
  25. }

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

  1. /**
  2. * Create the ButtonCellRenderer to be used as a renderer and editor. The
  3. * renderer and editor will automatically be installed on the TableColumn of
  4. * the specified column.
  5. *
  6. * @param table the table containing the button renderer/editor
  7. * @param action the Action to be invoked when the button is invoked
  8. * @param column the column to which the button renderer/editor is added
  9. */
  10. public ButtonCellRenderer(JTable table, Action action, int column) {
  11. this.table = table;
  12. this.action = action;
  13. renderButton = new JButton();
  14. editButton = new JButton();
  15. editButton.setFocusPainted(false);
  16. editButton.addActionListener(this);
  17. originalBorder = editButton.getBorder();
  18. setFocusBorder(new LineBorder(Color.BLUE));
  19. TableColumnModel columnModel = table.getColumnModel();
  20. columnModel.getColumn(column).setCellRenderer(this);
  21. columnModel.getColumn(column).setCellEditor(this);
  22. table.addMouseListener(this);
  23. }

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

  1. /**
  2. * Create the ButtonColumn to be used as a renderer and editor. The
  3. * renderer and editor will automatically be installed on the TableColumn
  4. * of the specified column.
  5. *
  6. * @param table the table containing the button renderer/editor
  7. * @param action the Action to be invoked when the button is invoked
  8. * @param column the column to which the button renderer/editor is added
  9. * @since 0.2.3
  10. */
  11. public ButtonColumn(JTable table, Action action, int column) {
  12. this.table = table;
  13. this.action = action;
  14. renderButton = new JButton();
  15. editButton = new JButton();
  16. editButton.setFocusPainted(false);
  17. editButton.addActionListener(this);
  18. originalBorder = editButton.getBorder();
  19. setFocusBorder(new LineBorder(Color.BLUE));
  20. TableColumnModel columnModel = table.getColumnModel();
  21. columnModel.getColumn(column).setCellRenderer(this);
  22. columnModel.getColumn(column).setCellEditor(this);
  23. table.addMouseListener(this);
  24. }

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

  1. /**
  2. * Create the ButtonColumn to be used as a renderer and editor. The
  3. * renderer and editor will automatically be installed on the TableColumn
  4. * of the specified column.
  5. *
  6. * @param table the table containing the button renderer/editor
  7. * @param action the Action to be invoked when the button is invoked
  8. * @param column the column to which the button renderer/editor is added
  9. */
  10. public ButtonColumn(JTable table, Action action, int column) {
  11. this.table = table;
  12. this.action = action;
  13. renderButton = new JButton();
  14. editButton = new JButton();
  15. editButton.setFocusPainted(false);
  16. editButton.addActionListener(this);
  17. originalBorder = editButton.getBorder();
  18. setFocusBorder(new LineBorder(Color.BLUE));
  19. TableColumnModel columnModel = table.getColumnModel();
  20. columnModel.getColumn(column).setCellRenderer(this);
  21. columnModel.getColumn(column).setCellEditor(this);
  22. table.addMouseListener(this);
  23. }

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

  1. /**
  2. * Create the ButtonColumn to be used as a renderer and editor. The renderer
  3. * and editor will automatically be installed on the TableColumn of the
  4. * specified column.
  5. *
  6. * @param table the table containing the button renderer/editor
  7. * @param action the Action to be invoked when the button is invoked
  8. * @param column the column to which the button renderer/editor is added
  9. */
  10. public ButtonColumn(JTable table, Action action, int column) {
  11. this.table = table;
  12. this.action = action;
  13. renderButton = new JButton();
  14. editButton = new JButton();
  15. editButton.setFocusPainted(false);
  16. editButton.addActionListener(this);
  17. originalBorder = editButton.getBorder();
  18. setFocusBorder(new LineBorder(Color.BLUE));
  19. TableColumnModel columnModel = table.getColumnModel();
  20. columnModel.getColumn(column).setCellRenderer(this);
  21. columnModel.getColumn(column).setCellEditor(this);
  22. table.addMouseListener(this);
  23. }

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

  1. /**
  2. * Create the ButtonColumn to be used as a renderer and editor. The renderer
  3. * and editor will automatically be installed on the TableColumn of the
  4. * specified column.
  5. *
  6. * @param table
  7. * the table containing the button renderer/editor
  8. * @param action
  9. * the Action to be invoked when the button is invoked
  10. * @param column
  11. * the column to which the button renderer/editor is added
  12. */
  13. public ButtonColumn(JTable table, Action action, int column) {
  14. this.table = table;
  15. this.action = action;
  16. renderButton = new JButton();
  17. editButton = new JButton();
  18. editButton.setFocusPainted(false);
  19. editButton.addActionListener(this);
  20. originalBorder = editButton.getBorder();
  21. setFocusBorder(new LineBorder(Color.BLUE));
  22. TableColumnModel columnModel = table.getColumnModel();
  23. columnModel.getColumn(column).setCellRenderer(this);
  24. columnModel.getColumn(column).setCellEditor(this);
  25. table.addMouseListener(this);
  26. }

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

  1. public static void equalizeButtonSizes(Graphics g, JButton... buttons) {
  2. String[] labels = BeanUtil.extractProperties(buttons, "text", String.class);
  3. // Get the largest width and height
  4. Dimension maxSize = new Dimension(0, 0);
  5. Rectangle2D textBounds = null;
  6. JButton button0 = buttons[0];
  7. FontMetrics metrics = button0.getFontMetrics(button0.getFont());
  8. for (int i = 0; i < labels.length; ++i) {
  9. textBounds = metrics.getStringBounds(labels[i], g);
  10. maxSize.width = Math.max(maxSize.width, (int) textBounds.getWidth());
  11. maxSize.height = Math.max(maxSize.height, (int) textBounds.getHeight());
  12. }
  13. Insets insets = button0.getBorder().getBorderInsets(button0);
  14. maxSize.width += insets.left + insets.right;
  15. maxSize.height += insets.top + insets.bottom;
  16. // reset preferred and maximum size since BoxLayout takes both into account
  17. for (JButton button : buttons) {
  18. button.setPreferredSize((Dimension) maxSize.clone());
  19. button.setMaximumSize((Dimension) maxSize.clone());
  20. }
  21. }

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

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

相关文章

JButton类方法