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

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

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

JButton.setMargin介绍

暂无

代码示例

代码示例来源:origin: kiegroup/optaplanner

  1. public static JButton makeSmallButton(JButton button) {
  2. button.setMargin(new Insets(0, 0, 0, 0));
  3. button.putClientProperty("Nimbus.Overrides", smallButtonUIDefaults);
  4. return button;
  5. }

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

  1. titlePanel.add(upButton);
  2. upButton.setText("Up");
  3. upButton.setMargin(new Insets(0, 0, 0, 0));
  4. Font font = upButton.getFont();
  5. upButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));
  6. titlePanel.add(downButton);
  7. downButton.setText("Down");
  8. downButton.setMargin(new Insets(0, 0, 0, 0));
  9. Font font = downButton.getFont();
  10. downButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));
  11. titlePanel.add(deleteButton);
  12. deleteButton.setText("X");
  13. deleteButton.setMargin(new Insets(0, 0, 0, 0));
  14. Font font = deleteButton.getFont();
  15. deleteButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));

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

  1. titlePanel.add(upButton);
  2. upButton.setText("Up");
  3. upButton.setMargin(new Insets(0, 0, 0, 0));
  4. Font font = upButton.getFont();
  5. upButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));
  6. titlePanel.add(downButton);
  7. downButton.setText("Down");
  8. downButton.setMargin(new Insets(0, 0, 0, 0));
  9. Font font = downButton.getFont();
  10. downButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));
  11. titlePanel.add(deleteButton);
  12. deleteButton.setText("X");
  13. deleteButton.setMargin(new Insets(0, 0, 0, 0));
  14. Font font = deleteButton.getFont();
  15. deleteButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));

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

  1. leftSidePanel.setLayout(new GridBagLayout());
  2. getContentPane().add(leftSidePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
  3. GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
  4. GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
  5. fontPanel.setLayout(new GridBagLayout());
  6. fontPanel.setBorder(BorderFactory.createTitledBorder("Font"));
  7. fontPanel.add(browseButton, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
  8. GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
  9. browseButton.setMargin(new Insets(0, 0, 0, 0));

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

  1. leftSidePanel.setLayout(new GridBagLayout());
  2. getContentPane().add(leftSidePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
  3. GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
  4. GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
  5. fontPanel.setLayout(new GridBagLayout());
  6. fontPanel.setBorder(BorderFactory.createTitledBorder("Font"));
  7. fontPanel.add(browseButton, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
  8. GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
  9. browseButton.setMargin(new Insets(0, 0, 0, 0));

代码示例来源:origin: bonnyfone/vectalign

  1. btnMorphAnimation.setBorderPainted(false);
  2. btnMorphAnimation.setBorder(null);
  3. btnMorphAnimation.setMargin(new Insets(0, 0, 0, 0));
  4. btnMorphAnimation.setContentAreaFilled(false);

代码示例来源:origin: magefree/mage

  1. public static JButton getButton () {
  2. JButton button = new JButton();
  3. button.setMargin(new Insets(2, 4, 2, 4));
  4. return button;
  5. }

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

  1. JButton button = new JButton();
  2. button.setBorderPainted(false);
  3. button.setBorder(null);
  4. //button.setFocusable(false);
  5. button.setMargin(new Insets(0, 0, 0, 0));
  6. button.setContentAreaFilled(false);
  7. button.setIcon(myIcon1);
  8. button.setRolloverIcon(myIcon2);
  9. button.setPressedIcon(myIcon3);
  10. button.setDisabledIcon(myIcon4);

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

  1. public DataControl(String nodePath, Port port) {
  2. super(nodePath, port);
  3. setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
  4. clearDataButton = new JButton("Clear");
  5. clearDataButton.setMargin(new Insets(1, 0, 0, 0));
  6. clearDataButton.putClientProperty("JButton.buttonType", "textured");
  7. clearDataButton.putClientProperty("JComponent.sizeVariant", "small");
  8. clearDataButton.setFont(Theme.SMALL_BOLD_FONT);
  9. clearDataButton.setForeground(Theme.TEXT_NORMAL_COLOR);
  10. clearDataButton.addActionListener(this);
  11. add(clearDataButton);
  12. /*showDataButton = new JButton("Show Data...");
  13. showDataButton.setMargin(new Insets(1, 0, 0, 0));
  14. showDataButton.putClientProperty("JButton.buttonType", "textured");
  15. showDataButton.putClientProperty("JComponent.sizeVariant", "small");
  16. showDataButton.setFont(Theme.SMALL_BOLD_FONT);
  17. showDataButton.setForeground(Theme.TEXT_NORMAL_COLOR);
  18. showDataButton.addActionListener(this);
  19. add(showDataButton);*/
  20. add(Box.createHorizontalGlue());
  21. }

代码示例来源:origin: magefree/mage

  1. btnConnect.setMargin(new java.awt.Insets(2, 2, 2, 2));
  2. btnConnect.addActionListener(new java.awt.event.ActionListener() {
  3. public void actionPerformed(java.awt.event.ActionEvent evt) {
  4. btnCancel.setMargin(new java.awt.Insets(2, 2, 2, 2));
  5. btnCancel.addActionListener(new java.awt.event.ActionListener() {
  6. public void actionPerformed(java.awt.event.ActionEvent evt) {
  7. btnRegister.setMargin(new java.awt.Insets(2, 2, 2, 2));
  8. btnRegister.addActionListener(new java.awt.event.ActionListener() {
  9. public void actionPerformed(java.awt.event.ActionEvent evt) {
  10. btnForgotPassword.setMargin(new java.awt.Insets(2, 2, 2, 2));
  11. btnForgotPassword.addActionListener(new java.awt.event.ActionListener() {
  12. public void actionPerformed(java.awt.event.ActionEvent evt) {
  13. btnFindMain.setActionCommand("connectXmageDe");
  14. btnFindMain.setAlignmentY(0.0F);
  15. btnFindMain.setMargin(new java.awt.Insets(2, 2, 2, 2));
  16. btnFindMain.setMaximumSize(new java.awt.Dimension(42, 23));
  17. btnFindMain.setMinimumSize(new java.awt.Dimension(42, 23));
  18. btnFindLocal.setAlignmentY(0.0F);
  19. btnFindLocal.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  20. btnFindLocal.setMargin(new java.awt.Insets(2, 2, 2, 2));
  21. btnFindLocal.setName("connectLocalhostBtn"); // NOI18N
  22. btnFindLocal.setPreferredSize(new java.awt.Dimension(23, 23));
  23. btnFindBeta.setAlignmentY(0.0F);

代码示例来源:origin: magefree/mage

  1. jToggleListView.setFocusable(false);
  2. jToggleListView.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  3. jToggleListView.setMargin(new java.awt.Insets(2, 2, 2, 2));
  4. jToggleListView.setMaximumSize(new java.awt.Dimension(37, 22));
  5. jToggleListView.setMinimumSize(new java.awt.Dimension(37, 22));
  6. jToggleCardView.setFocusable(false);
  7. jToggleCardView.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  8. jToggleCardView.setMargin(new java.awt.Insets(2, 2, 2, 2));
  9. jToggleCardView.setMaximumSize(new java.awt.Dimension(37, 22));
  10. jToggleCardView.setMinimumSize(new java.awt.Dimension(37, 22));
  11. jButtonAddToMain.setMargin(null);
  12. jButtonAddToMain.setMaximumSize(new java.awt.Dimension(35, 23));
  13. jButtonAddToMain.setMinimumSize(new java.awt.Dimension(35, 23));
  14. jButtonRemoveFromMain.setMargin(null);
  15. jButtonRemoveFromMain.setMaximumSize(new java.awt.Dimension(42, 23));
  16. jButtonRemoveFromMain.setMinimumSize(new java.awt.Dimension(42, 23));
  17. jButtonAddToSideboard.setMargin(new java.awt.Insets(2, 0, 2, 0));
  18. jButtonAddToSideboard.setMaximumSize(new java.awt.Dimension(100, 30));
  19. jButtonAddToSideboard.setMinimumSize(new java.awt.Dimension(10, 30));
  20. jButtonRemoveFromSideboard.setMargin(new java.awt.Insets(2, 0, 2, 0));
  21. jButtonRemoveFromSideboard.setMaximumSize(new java.awt.Dimension(10, 30));
  22. jButtonRemoveFromSideboard.setMinimumSize(new java.awt.Dimension(100, 30));

代码示例来源:origin: magefree/mage

  1. btnNewTable.setMargin(new java.awt.Insets(2, 2, 2, 2));
  2. btnNewTable.addActionListener(evt -> btnNewTableActionPerformed(evt));
  3. btnNewTournament.setMargin(new java.awt.Insets(2, 2, 2, 2));
  4. btnNewTournament.addActionListener(evt -> btnNewTournamentActionPerformed(evt));

代码示例来源:origin: Renanse/Ardor3D

  1. protected JButton makeListButton(final String text) {
  2. final JButton button = new JButton(text);
  3. button.setMargin(new Insets(2, 2, 2, 2));
  4. return button;
  5. }

代码示例来源:origin: info.aduna.commons/aduna-commons-swing

  1. private JButton createButton(String text) {
  2. JButton button = new JButton(text);
  3. button.setMargin(new Insets(2, 18, 3, 18));
  4. button.addActionListener(this);
  5. return button;
  6. }

代码示例来源:origin: MarginallyClever/Makelangelo-software

  1. public JButton createTightJButton(String label) {
  2. JButton b = new JButton(label);
  3. b.setMargin(new Insets(0,0,0,0));
  4. b.setPreferredSize(new Dimension(60,20));
  5. b.addActionListener(this);
  6. return b;
  7. }

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

  1. lines = new char[][]{...};
  2. for (int outter = 0; outter < lines.length; outter++) {
  3. JPanel panel = new JPanel(new GridBagLayout());
  4. for (int inner = 0; inner < lines[outter].length) {
  5. char ch = lines[outter][inner];
  6. JButton btn = new JButton(Character.toString(ch));
  7. btn.setMargin(new Insets(10, 10, 10, 10));
  8. panel.add(btn);
  9. }
  10. add(panel, gbc);
  11. gbc.gridy++;
  12. }

代码示例来源:origin: MarginallyClever/Makelangelo-software

  1. public JButton createNarrowJButton(String label) {
  2. JButton b = new JButton(label);
  3. b.setMargin(new Insets(0,0,0,0));
  4. b.setPreferredSize(new Dimension(40,20));
  5. b.addActionListener(this);
  6. return b;
  7. }

代码示例来源:origin: locationtech/jts

  1. public static JButton createButton(ImageIcon icon, String tip, ActionListener action ) {
  2. JButton btn = new JButton();
  3. btn.setToolTipText(tip);
  4. btn.setIcon(icon);
  5. btn.setMargin(new Insets(0, 0, 0, 0));
  6. if (action != null) btn.addActionListener(action);
  7. btn.setFocusable(false);
  8. btn.setFocusPainted(false);
  9. return btn;
  10. }

代码示例来源:origin: org.scijava/scijava-ui-swing

  1. public static JButton createButton16(final ImageIcon icon,
  2. final String toolTip)
  3. {
  4. final JButton newButton = new JButton();
  5. newButton.setMargin(new Insets(0, 0, 0, 0));
  6. newButton.setMinimumSize(new Dimension(16, 16));
  7. if (toolTip != null) {
  8. newButton.setToolTipText(toolTip);
  9. }
  10. newButton.setIcon(icon);
  11. return newButton;
  12. }

代码示例来源:origin: net.imagej/ij-ui-swing

  1. public static JButton createButton16(ImageIcon icon, String toolTip) {
  2. JButton newButton = new JButton();
  3. newButton.setMargin(new Insets(0, 0, 0, 0));
  4. newButton.setMinimumSize(new Dimension(16, 16));
  5. if (toolTip != null) {
  6. newButton.setToolTipText(toolTip);
  7. }
  8. newButton.setIcon(icon);
  9. return newButton;
  10. }

相关文章

JButton类方法