List of usage examples for javax.swing JToggleButton setUI
@BeanProperty(hidden = true, visualUpdate = true, description = "The UI object that implements the LookAndFeel.") public void setUI(ButtonUI ui)
From source file:org.tinymediamanager.ui.dialogs.ImageChooserDialog.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private void addImage(BufferedImage originalImage, final MediaArtwork artwork) { Point size = null;//from w ww . j ava 2 s . c o m 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(); }