List of usage examples for javax.swing JToggleButton setIcon
@BeanProperty(visualUpdate = true, description = "The button's default icon") public void setIcon(Icon defaultIcon)
From source file:Main.java
public static JToggleButton createToggleButton(ImageIcon icon, int dimension, String tooltipText) { JToggleButton btn = new JToggleButton(); btn.setToolTipText(tooltipText);//from w w w .jav a 2 s. co m 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:components.CrayonPanel.java
protected JToggleButton createCrayon(String name, Border normalBorder) { JToggleButton crayon = new JToggleButton(); crayon.setActionCommand(name);/*from w ww.j a v a 2 s. c o m*/ crayon.addActionListener(this); //Set the image or, if that's invalid, equivalent text. ImageIcon icon = createImageIcon("images/" + name + ".gif"); if (icon != null) { crayon.setIcon(icon); crayon.setToolTipText("The " + name + " crayon"); crayon.setBorder(normalBorder); } else { crayon.setText("Image not found. This is the " + name + " button."); crayon.setFont(crayon.getFont().deriveFont(Font.ITALIC)); crayon.setHorizontalAlignment(JButton.HORIZONTAL); crayon.setBorder(BorderFactory.createLineBorder(Color.BLACK)); } return crayon; }
From source file:org.nbheaven.sqe.codedefects.history.controlcenter.panels.SQEHistoryPanel.java
/** Creates new form SQEHistoryPanel */ public SQEHistoryPanel() { historyChart = org.jfree.chart.ChartFactory.createStackedXYAreaChart(null, "Snapshot", "CodeDefects", perProjectDataSet, PlotOrientation.VERTICAL, false, true, false); historyChart.setBackgroundPaint(Color.WHITE); historyChart.getXYPlot().setRangeGridlinePaint(Color.BLACK); historyChart.getXYPlot().setDomainGridlinePaint(Color.BLACK); historyChart.getXYPlot().setBackgroundPaint(Color.WHITE); XYPlot plot = historyChart.getXYPlot(); plot.setForegroundAlpha(0.7f);//w w w .j a va 2 s .c o m // plot.getRenderer(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LogarithmicAxis rangeAxis = new LogarithmicAxis("CodeDefects"); rangeAxis.setStrictValuesFlag(false); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setRangeAxis(rangeAxis); StackedXYAreaRenderer2 categoryItemRenderer = new StackedXYAreaRenderer2(); //3D(); categoryItemRenderer.setSeriesPaint(0, Color.RED); categoryItemRenderer.setSeriesPaint(1, Color.ORANGE); categoryItemRenderer.setSeriesPaint(2, Color.YELLOW); plot.setRenderer(categoryItemRenderer); ChartPanel historyChartPanel = new ChartPanel(historyChart); historyChartPanel.setBorder(null); historyChartPanel.setPreferredSize(new Dimension(150, 200)); historyChartPanel.setBackground(Color.WHITE); initComponents(); historyView.setLayout(new BorderLayout()); historyView.add(historyChartPanel, BorderLayout.CENTER); JPanel selectorPanel = new JPanel(); selectorPanel.setOpaque(false); GroupLayout layout = new GroupLayout(selectorPanel); selectorPanel.setLayout(layout); // Turn on automatically adding gaps between components layout.setAutocreateGaps(true); // Turn on automatically creating gaps between components that touch // the edge of the container and the container. layout.setAutocreateContainerGaps(true); ParallelGroup horizontalParallelGroup = layout.createParallelGroup(GroupLayout.LEADING); SequentialGroup verticalSequentialGroup = layout.createSequentialGroup(); layout.setHorizontalGroup(layout.createSequentialGroup().add(horizontalParallelGroup)); layout.setVerticalGroup(verticalSequentialGroup); clearHistoryButton = new JButton(); clearHistoryButton.setEnabled(false); clearHistoryButton.setIcon(ImageUtilities .image2Icon(ImageUtilities.loadImage("org/nbheaven/sqe/codedefects/history/resources/trash.png"))); clearHistoryButton.setOpaque(false); clearHistoryButton.setFocusPainted(false); clearHistoryButton.setToolTipText( NbBundle.getBundle("org/nbheaven/sqe/codedefects/history/controlcenter/panels/Bundle") .getString("HINT_clear_button")); horizontalParallelGroup.add(clearHistoryButton); verticalSequentialGroup.add(clearHistoryButton); clearHistoryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (null != activeHistory) { activeHistory.clear(); } } }); Component createVerticalStrut = Box.createVerticalStrut(10); horizontalParallelGroup.add(createVerticalStrut); verticalSequentialGroup.add(createVerticalStrut); for (final QualityProvider provider : SQEUtilities.getProviders()) { final JToggleButton providerButton = new JToggleButton(); providerButton.setIcon(provider.getIcon()); providerButton.setOpaque(false); providerButton.setFocusPainted(false); horizontalParallelGroup.add(providerButton); verticalSequentialGroup.add(providerButton); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (providerButton.isSelected()) { addSelectedProvider(provider); } else { removeSelectedProvider(provider); } updateView(); } }; providerButton.addActionListener(listener); addSelectedProvider(provider); providerButton.setSelected(true); } historyView.add(selectorPanel, BorderLayout.EAST); }
From source file:be.nbb.demetra.dfm.DfmExecViewTopComponent.java
@Override public JComponent getToolbarRepresentation() { JToolBar toolBar = NbComponents.newInnerToolbar(); toolBar.addSeparator();//from www .ja v a 2 s . c o m toolBar.add(Box.createRigidArea(new Dimension(5, 0))); JToggleButton startStop = (JToggleButton) toolBar .add(new JToggleButton(StartStopCommand.INSTANCE.toAction(this))); startStop.setIcon(DemetraUiIcon.COMPILE_16); startStop.setDisabledIcon(createDisabledIcon(startStop.getIcon())); startStop.setToolTipText("Start/Stop"); JButton edit = toolBar.add(EditSpecCommand.INSTANCE.toAction(this)); edit.setIcon(DemetraUiIcon.PREFERENCES); edit.setDisabledIcon(createDisabledIcon(edit.getIcon())); edit.setToolTipText("Specification"); JButton clear = toolBar.add(ClearCommand.INSTANCE.toAction(this)); clear.setIcon(DemetraUiIcon.EDIT_CLEAR_16); clear.setDisabledIcon(createDisabledIcon(clear.getIcon())); clear.setToolTipText("Clear"); SwingColorSchemeSupport colorSchemeSupport = SwingColorSchemeSupport .from(DemetraUI.getInstance().getColorScheme()); sparkline = (ChartPanel) toolBar .add(Charts.avoidScaling(new ChartPanel(Charts.createSparkLineChart(null)))); sparkline.setPreferredSize(new Dimension(150, 16)); sparkline.setMaximumSize(new Dimension(150, 16)); sparkline.getChart().getXYPlot().setDataset(dataset); sparkline.getChart().getXYPlot().getRenderer() .setBasePaint(colorSchemeSupport.getLineColor(ColorScheme.KnownColor.GREEN)); sparkline.setBackground(colorSchemeSupport.getPlotColor()); sparkline.setBorder(BorderFactory.createLineBorder(colorSchemeSupport.getGridColor())); sparkline.setToolTipText("loglikelihood"); return toolBar; }
From source file:com.eviware.soapui.impl.wsdl.monitor.SoapMonitor.java
/** * Method start/*from ww w. java 2 s . c o m*/ */ public void start() { int localPort = getLocalPort(); // monitorEngine = new TcpMonMonitorEngine(); monitorEngine = new SoapMonitorEngineImpl(); ((SoapMonitorEngineImpl) monitorEngine).setSslEndpoint(sslEndpoint); monitorEngine.start(this, localPort); if (monitorEngine.isRunning()) { stopButton.setEnabled(true); startButton.setEnabled(false); optionsButton.setEnabled(false); infoLabel.setText((monitorEngine.isProxy() ? "HTTP Proxy " : "SSL Tunnel ") + "on port " + localPort); progressBar.setIndeterminate(true); if (setAsProxy) { oldProxyHost = SoapUI.getSettings().getString(ProxySettings.HOST, ""); oldProxyPort = SoapUI.getSettings().getString(ProxySettings.PORT, ""); oldProxyEnabled = SoapUI.getSettings().getBoolean(ProxySettings.ENABLE_PROXY); SoapUI.getSettings().setString(ProxySettings.HOST, "127.0.0.1"); SoapUI.getSettings().setString(ProxySettings.PORT, String.valueOf(localPort)); SoapUI.getSettings().setBoolean(ProxySettings.ENABLE_PROXY, true); SoapUI.setProxyEnabled(true); JToggleButton applyProxyButton = (JToggleButton) SoapUI.getApplyProxyButton(); if (applyProxyButton != null) applyProxyButton.setIcon(UISupport.createImageIcon(SoapUI.PROXY_ENABLED_ICON)); } SoapUI.log.info("Started HTTP Monitor on local port " + localPort); } else { stopButton.setEnabled(false); startButton.setEnabled(true); optionsButton.setEnabled(true); infoLabel.setText("Stopped"); progressBar.setIndeterminate(false); SoapUI.log.info("Could not start HTTP Monitor on local port " + localPort); } }
From source file:com.eviware.soapui.impl.wsdl.monitor.SoapMonitor.java
/** * Method stop//from ww w . j av a2 s.co m */ public void stop() { monitorEngine.stop(); if (addedEndpoints != null) { for (Interface iface : addedEndpoints.keySet()) iface.removeEndpoint(addedEndpoints.get(iface)); addedEndpoints.clear(); } stopButton.setEnabled(false); startButton.setEnabled(true); optionsButton.setEnabled(true); progressBar.setIndeterminate(false); infoLabel.setText("Stopped"); if (setAsProxy) { SoapUI.getSettings().setString(ProxySettings.HOST, oldProxyHost); SoapUI.getSettings().setString(ProxySettings.PORT, oldProxyPort); SoapUI.getSettings().setBoolean(ProxySettings.ENABLE_PROXY, oldProxyEnabled); SoapUI.setProxyEnabled(oldProxyEnabled); JToggleButton applyProxyButton = (JToggleButton) SoapUI.getApplyProxyButton(); if (applyProxyButton != null) { if (oldProxyEnabled) { applyProxyButton.setIcon(UISupport.createImageIcon(SoapUI.PROXY_ENABLED_ICON)); } else { applyProxyButton.setIcon(UISupport.createImageIcon(SoapUI.PROXY_DISABLED_ICON)); } } } }
From source file:de.tor.tribes.ui.views.DSWorkbenchStatsFrame.java
private void buildMenu() { JXTaskPane editPane = new JXTaskPane(); editPane.setTitle("Bearbeiten"); final JToggleButton createStats = new JToggleButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/medal.png"))); createStats.setToolTipText(/*from w w w . j a v a 2 s . c om*/ "Umschalten zwischen dem Erzeugen von Statistiken und der Anzeige von Verlaufsgrafiken"); createStats.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { boolean showChartView = !createStats.isSelected(); if (showChartView) { createStats .setIcon(new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/medal.png"))); } else { createStats .setIcon(new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/chart.png"))); } switchStatChartView(showChartView); } }); JXButton selectStart = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/beginning.png"))); selectStart.setToolTipText("Setzt eine Startmarkierung beim gewhlten Datenpunkt"); selectStart.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { setStartAnnotation(); } }); selectStart.setSize(createStats.getSize()); selectStart.setMinimumSize(createStats.getMinimumSize()); selectStart.setMaximumSize(createStats.getMaximumSize()); selectStart.setPreferredSize(createStats.getPreferredSize()); editPane.getContentPane().add(selectStart); JXButton selectEnd = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/end.png"))); selectEnd.setToolTipText("Setzt eine Endmarkierung beim gewhlten Datenpunkt"); selectEnd.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { setEndAnnotation(); } }); selectEnd.setSize(createStats.getSize()); selectEnd.setMinimumSize(createStats.getMinimumSize()); selectEnd.setMaximumSize(createStats.getMaximumSize()); selectEnd.setPreferredSize(createStats.getPreferredSize()); editPane.getContentPane().add(selectEnd); JXButton removeSelection = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/delete_region.png"))); removeSelection.setToolTipText("Lscht alle Datenpunkte zwischen der Start- und Endmarkierung"); removeSelection.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { removeSelection(); } }); removeSelection.setSize(createStats.getSize()); removeSelection.setMinimumSize(createStats.getMinimumSize()); removeSelection.setMaximumSize(createStats.getMaximumSize()); removeSelection.setPreferredSize(createStats.getPreferredSize()); editPane.getContentPane().add(removeSelection); createStats.setSize(removeSelection.getSize()); createStats.setMinimumSize(removeSelection.getMinimumSize()); createStats.setMaximumSize(removeSelection.getMaximumSize()); createStats.setPreferredSize(removeSelection.getPreferredSize()); editPane.getContentPane().add(createStats); JXTaskPane viewPane = new JXTaskPane(); viewPane.setTitle("Anzeige"); viewPane.getContentPane().add(jViewSelectionBox); JXTaskPane settingsPane = new JXTaskPane(); settingsPane.setTitle("Einstellungen"); settingsPane.getContentPane().add(jShowItemValues); settingsPane.getContentPane().add(jShowLegend); settingsPane.getContentPane().add(jShowLines); settingsPane.getContentPane().add(jShowDataPoints); centerPanel.setupTaskPane(editPane, viewPane, settingsPane); }
From source file:org.revager.tools.GUITools.java
/** * Creates a new image toggle button./* www . j a v a 2s . c om*/ * * @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.tinymediamanager.ui.dialogs.ImageChooserDialog.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private void addImage(BufferedImage originalImage, final MediaArtwork artwork) { Point size = null;//from w w w . j a v a 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(); }