List of usage examples for javax.swing JToggleButton setMargin
@BeanProperty(visualUpdate = true, description = "The space between the button's border and the label.") public void setMargin(Insets m)
From source file:Main.java
public static void main(String[] argv) throws Exception { JToolBar toolbar = new JToolBar(); ImageIcon icon = new ImageIcon("icon.gif"); Action action = new AbstractAction("Button Label", icon) { public void actionPerformed(ActionEvent evt) { }//w w w . java 2s.co m }; JButton c1 = new JButton(action); c1.setText(null); c1.setMargin(new Insets(0, 0, 0, 0)); toolbar.add(c1); JToggleButton c2 = new JToggleButton(action); c2.setText(null); c2.setMargin(new Insets(0, 0, 0, 0)); toolbar.add(c2); JComboBox c3 = new JComboBox(new String[] { "A", "B", "C" }); c3.setPrototypeDisplayValue("XXXXXXXX"); // Set a desired width c3.setMaximumSize(c3.getMinimumSize()); toolbar.add(c3); }
From source file:Main.java
public static JToggleButton createToggleButton(ImageIcon icon, int dimension, String tooltipText) { JToggleButton btn = new JToggleButton(); btn.setToolTipText(tooltipText);// w ww . j a va 2 s. c om btn.setIcon(icon); btn.setMaximumSize(new Dimension(dimension, dimension)); btn.setMinimumSize(new Dimension(dimension, dimension)); btn.setPreferredSize(new Dimension(dimension, dimension)); btn.setMargin(new Insets(0, 0, 0, 0)); return btn; }
From source file:io.gameover.utilities.pixeleditor.Pixelizer.java
private void addSelectFrameButtonToPanel(int index) { JToggleButton button = new JToggleButton("" + index); button.setPreferredSize(new Dimension(20, 20)); button.setMargin(new Insets(0, 0, 0, 0)); button.setFont(button.getFont().deriveFont(9f)); button.setActionCommand("" + (index - 1)); button.addActionListener(getSelectFrameActionListener()); button.addMouseListener(new SelectFramePopClickListener(this, index - 1)); this.selectFrameButtons.add(button); this.selectFramePanel.add(button, LayoutUtils.xyi((index - 1) % 4 + 1, (index - 1) / 4 + 1, 0d, 0d, new Insets(1, 1, 1, 1))); }
From source file:org.revager.tools.GUITools.java
/** * Creates a new image toggle button.//from ww w . ja v a2s . c o m * * @param icon * the normal icon * @param rolloverIcon * the rollover icon * @param action * the action * * @return the newly created image button */ public static JToggleButton newImageToggleButton(ImageIcon icon, ImageIcon rolloverIcon, Action action) { JToggleButton button = new JToggleButton(action); button.setToolTipText(button.getText()); button.setText(null); button.setContentAreaFilled(false); button.setBorder(new EmptyBorder(0, 0, 0, 0)); button.setMargin(new Insets(0, 0, 0, 0)); button.setBorderPainted(false); button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); button.setFocusPainted(false); button.setFocusable(false); button.setIcon(icon); button.setRolloverIcon(rolloverIcon); button.setRolloverSelectedIcon(rolloverIcon); button.setSelectedIcon(rolloverIcon); return button; }
From source file:org.revager.tools.GUITools.java
/** * Creates a new image toggle button.//from www .ja va 2 s . c o m * * @return the newly created image toggle button */ public static JToggleButton newImageToggleButton() { JToggleButton button = new JToggleButton(); button.setBorder(new EmptyBorder(2, 2, 2, 8)); button.setMargin(new Insets(0, 0, 0, 0)); button.setBorderPainted(false); button.setOpaque(false); button.setContentAreaFilled(false); button.setFocusable(false); button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); return button; }
From source file:org.tinymediamanager.ui.dialogs.ImageChooserDialog.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private void addImage(BufferedImage originalImage, final MediaArtwork artwork) { Point size = null;/* www. java 2 s . c om*/ GridBagLayout gbl = new GridBagLayout(); switch (type) { case FANART: case CLEARART: case THUMB: case DISC: gbl.columnWidths = new int[] { 130 }; gbl.rowHeights = new int[] { 180 }; size = ImageCache.calculateSize(300, 150, originalImage.getWidth(), originalImage.getHeight(), true); break; case BANNER: case LOGO: case CLEARLOGO: gbl.columnWidths = new int[] { 130 }; gbl.rowHeights = new int[] { 120 }; size = ImageCache.calculateSize(300, 100, originalImage.getWidth(), originalImage.getHeight(), true); break; case POSTER: default: gbl.columnWidths = new int[] { 180 }; gbl.rowHeights = new int[] { 270 }; size = ImageCache.calculateSize(150, 250, originalImage.getWidth(), originalImage.getHeight(), true); break; } gbl.columnWeights = new double[] { Double.MIN_VALUE }; gbl.rowWeights = new double[] { Double.MIN_VALUE }; JPanel imagePanel = new JPanel(); imagePanel.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 3; gbc.insets = new Insets(5, 5, 5, 5); JToggleButton button = new JToggleButton(); button.setBackground(Color.white); button.setUI(toggleButtonUI); button.setMargin(new Insets(10, 10, 10, 10)); ImageIcon imageIcon = new ImageIcon(Scalr.resize(originalImage, Scalr.Method.BALANCED, Scalr.Mode.AUTOMATIC, size.x, size.y, Scalr.OP_ANTIALIAS)); button.setIcon(imageIcon); button.putClientProperty("MediaArtwork", artwork); buttonGroup.add(button); buttons.add(button); imagePanel.add(button, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.LAST_LINE_START; gbc.insets = new Insets(0, 5, 0, 0); JComboBox cb = null; if (artwork.getImageSizes().size() > 0) { cb = new JComboBox(artwork.getImageSizes().toArray()); } else { cb = new JComboBox(new String[] { originalImage.getWidth() + "x" + originalImage.getHeight() }); } button.putClientProperty("MediaArtworkSize", cb); imagePanel.add(cb, gbc); // should we provide an option for extrathumbs if (mediaType == MediaType.MOVIE && type == ImageType.FANART && MovieModuleManager.MOVIE_SETTINGS.isImageExtraThumbs()) { gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.anchor = GridBagConstraints.LINE_END; JLabel label = new JLabel("Extrathumb"); imagePanel.add(label, gbc); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 1; gbc.anchor = GridBagConstraints.LINE_END; JCheckBox chkbx = new JCheckBox(); button.putClientProperty("MediaArtworkExtrathumb", chkbx); imagePanel.add(chkbx, gbc); } // should we provide an option for extrafanart if (mediaType == MediaType.MOVIE && type == ImageType.FANART && MovieModuleManager.MOVIE_SETTINGS.isImageExtraFanart()) { gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = MovieModuleManager.MOVIE_SETTINGS.isImageExtraThumbs() ? 2 : 1; gbc.anchor = GridBagConstraints.LINE_END; JLabel label = new JLabel("Extrafanart"); imagePanel.add(label, gbc); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = MovieModuleManager.MOVIE_SETTINGS.isImageExtraThumbs() ? 2 : 1; gbc.anchor = GridBagConstraints.LINE_END; JCheckBox chkbx = new JCheckBox(); button.putClientProperty("MediaArtworkExtrafanart", chkbx); imagePanel.add(chkbx, gbc); } /* show image button */ gbc.gridx = 0; gbc.gridy++; gbc.anchor = GridBagConstraints.LAST_LINE_START; gbc.gridwidth = 3; gbc.insets = new Insets(0, 0, 0, 0); JButton btnShowImage = new JButton("<html><font color=\"#0000CF\"><u>" + BUNDLE.getString("image.showoriginal") + "</u></font></html>"); btnShowImage.setBorderPainted(false); btnShowImage.setFocusPainted(false); btnShowImage.setContentAreaFilled(false); btnShowImage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ImagePreviewDialog dialog = new ImagePreviewDialog(artwork.getDefaultUrl()); dialog.setVisible(true); } }); imagePanel.add(btnShowImage, gbc); panelImages.add(imagePanel); panelImages.validate(); panelImages.getParent().validate(); }