List of usage examples for javax.swing JToggleButton setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:Main.java
/** Constructs a JToggleButton with an icon from the given file id. */ public static JToggleButton makeToggleButton(final Object owner, final String id, final String altText, final int wpad, final int hpad) { final URL url = owner.getClass().getResource(id); ImageIcon icon = null;//from w w w.j a v a 2s .c o m if (url != null) icon = new ImageIcon(url); JToggleButton button; if (icon == null) button = new JToggleButton(altText); else { button = new JToggleButton(icon); button.setPreferredSize(new Dimension(icon.getIconWidth() + wpad, icon.getIconHeight() + hpad)); } return button; }
From source file:Main.java
public static JToggleButton createToggleButton(ImageIcon icon, int dimension, String tooltipText) { JToggleButton btn = new JToggleButton(); btn.setToolTipText(tooltipText);/*w w w . j a v a2s.c o 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:dk.dma.epd.common.prototype.gui.notification.ChatServicePanel.java
/** * Creates a diminutive toggle button used for selecting the message type * /*from w ww. j a v a2 s. com*/ * @param title * the title of the button * @param icon * the icon to use * @param selected * whether the button is selected or not * @param group * the group to add the button to * @return the instantiated button */ private JToggleButton createMessageTypeButton(String title, ImageIcon icon, boolean selected, ButtonGroup group) { JToggleButton button = new JToggleButton(icon); group.add(button); button.setSelected(selected); button.setToolTipText(title); button.setFocusable(false); button.setFocusPainted(false); button.addActionListener(this); button.setPreferredSize(new Dimension(18, 18)); return button; }
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:com.maxl.java.amikodesk.AMiKoDesk.java
private static void setupButton(JToggleButton button, String toolTipText, String rolloverImg, String selectedImg) {/*from w w w .j av a 2 s . co m*/ button.setFont(new Font("Dialog", Font.PLAIN, 12)); button.setVerticalTextPosition(SwingConstants.BOTTOM); button.setHorizontalTextPosition(SwingConstants.CENTER); button.setText(toolTipText); button.setRolloverIcon(new ImageIcon(Constants.IMG_FOLDER + rolloverImg)); button.setSelectedIcon(new ImageIcon(Constants.IMG_FOLDER + selectedImg)); button.setBackground(m_selected_but_color); button.setToolTipText(toolTipText); // Remove border Border emptyBorder = BorderFactory.createEmptyBorder(); button.setBorder(emptyBorder); // Set adequate size button.setPreferredSize(new Dimension(32, 32)); }
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 . ja v a 2 s. c o m*/ "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); }