List of usage examples for javax.swing JButton setBorderPainted
@BeanProperty(visualUpdate = true, description = "Whether the border should be painted.") public void setBorderPainted(boolean b)
borderPainted
property. From source file:org.revager.tools.GUITools.java
/** * Creates a new invisible strut button. * /*from w w w. j a v a 2 s . c o m*/ * @return the newly created button */ public static JButton newInvisibleStrutButton() { JButton button = new JButton(" "); button.setContentAreaFilled(false); button.setBorder(null); button.setBorderPainted(false); button.setFocusable(false); button.setEnabled(false); 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 av a 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(); }
From source file:org.tinymediamanager.ui.MainWindow.java
/** * Create the application.//from w w w .j a v a 2 s .c o m * * @param name * the name */ public MainWindow(String name) { super(name); setName("mainWindow"); setMinimumSize(new Dimension(1000, 700)); instance = this; JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnTmm = new JMenu("tinyMediaManager"); mnTmm.setMnemonic(KeyEvent.VK_T); menuBar.add(mnTmm); if (!Globals.isDonator()) { mnTmm.add(new RegisterDonatorVersionAction()); } mnTmm.add(new SettingsAction()); mnTmm.addSeparator(); mnTmm.add(new LaunchUpdaterAction()); mnTmm.addSeparator(); mnTmm.add(new ExitAction()); initialize(); // tools menu JMenu tools = new JMenu(BUNDLE.getString("tmm.tools")); //$NON-NLS-1$ tools.setMnemonic(KeyEvent.VK_O); tools.add(new ClearDatabaseAction()); JMenu cache = new JMenu(BUNDLE.getString("tmm.cache")); //$NON-NLS-1$ cache.setMnemonic(KeyEvent.VK_C); tools.add(cache); JMenuItem clearImageCache = new JMenuItem(new ClearImageCacheAction()); clearImageCache.setMnemonic(KeyEvent.VK_I); cache.add(clearImageCache); JMenuItem rebuildImageCache = new JMenuItem(new RebuildImageCacheAction()); rebuildImageCache.setMnemonic(KeyEvent.VK_R); cache.add(rebuildImageCache); JMenuItem tmmFolder = new JMenuItem(BUNDLE.getString("tmm.gotoinstalldir")); //$NON-NLS-1$ tmmFolder.setMnemonic(KeyEvent.VK_I); tools.add(tmmFolder); tmmFolder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Path path = Paths.get(System.getProperty("user.dir")); try { // check whether this location exists if (Files.exists(path)) { TmmUIHelper.openFile(path); } } catch (Exception ex) { LOGGER.error("open filemanager", ex); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path, "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() })); } } }); JMenuItem tmmLogs = new JMenuItem(BUNDLE.getString("tmm.errorlogs")); //$NON-NLS-1$ tmmLogs.setMnemonic(KeyEvent.VK_L); tools.add(tmmLogs); tmmLogs.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JDialog logDialog = new LogDialog(); logDialog.setLocationRelativeTo(MainWindow.getActiveInstance()); logDialog.setVisible(true); } }); JMenuItem tmmMessages = new JMenuItem(BUNDLE.getString("tmm.messages")); //$NON-NLS-1$ tmmMessages.setMnemonic(KeyEvent.VK_L); tools.add(tmmMessages); tmmMessages.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JDialog messageDialog = MessageHistoryDialog.getInstance(); messageDialog.setVisible(true); } }); tools.addSeparator(); final JMenu menuWakeOnLan = new JMenu(BUNDLE.getString("tmm.wakeonlan")); //$NON-NLS-1$ menuWakeOnLan.setMnemonic(KeyEvent.VK_W); menuWakeOnLan.addMenuListener(new MenuListener() { @Override public void menuCanceled(MenuEvent arg0) { } @Override public void menuDeselected(MenuEvent arg0) { } @Override public void menuSelected(MenuEvent arg0) { menuWakeOnLan.removeAll(); for (final WolDevice device : Globals.settings.getWolDevices()) { JMenuItem item = new JMenuItem(device.getName()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Utils.sendWakeOnLanPacket(device.getMacAddress()); } }); menuWakeOnLan.add(item); } } }); tools.add(menuWakeOnLan); // activate/deactivate WakeOnLan menu item tools.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { if (Globals.settings.getWolDevices().size() > 0) { menuWakeOnLan.setEnabled(true); } else { menuWakeOnLan.setEnabled(false); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); if (Globals.isDebug()) { final JMenu debugMenu = new JMenu("Debug"); //$NON-NLS-1$ JMenuItem trace = new JMenuItem("set Logger to TRACE"); //$NON-NLS-1$ trace.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); lc.getLogger("org.tinymediamanager").setLevel(Level.TRACE); MessageManager.instance.pushMessage(new Message("Trace levels set!", "")); LOGGER.trace("if you see that, we're now on TRACE logging level ;)"); } }); debugMenu.add(trace); tools.add(debugMenu); } menuBar.add(tools); mnTmm = new JMenu(BUNDLE.getString("tmm.contact")); //$NON-NLS-1$ mnTmm.setMnemonic(KeyEvent.VK_C); mnTmm.add(new FeedbackAction()).setMnemonic(KeyEvent.VK_F); mnTmm.add(new BugReportAction()).setMnemonic(KeyEvent.VK_B); menuBar.add(mnTmm); mnTmm = new JMenu(BUNDLE.getString("tmm.help")); //$NON-NLS-1$ mnTmm.setMnemonic(KeyEvent.VK_H); menuBar.add(mnTmm); mnTmm.add(new WikiAction()).setMnemonic(KeyEvent.VK_W); mnTmm.add(new FaqAction()).setMnemonic(KeyEvent.VK_F); mnTmm.add(new ForumAction()).setMnemonic(KeyEvent.VK_O); mnTmm.addSeparator(); mnTmm.add(new AboutAction()).setMnemonic(KeyEvent.VK_A); menuBar.add(Box.createGlue()); if (!Globals.isDonator()) { JButton btnDonate = new JButton(new DonateAction()); btnDonate.setBorderPainted(false); btnDonate.setFocusPainted(false); btnDonate.setContentAreaFilled(false); menuBar.add(btnDonate); } checkForUpdate(); }
From source file:org.ut.biolab.medsavant.client.view.component.SearchableTablePanel.java
private JButton niceButton() { JButton b = new JButton(); b.setBorder(null);// w w w . jav a 2s. c o m b.setBorderPainted(false); b.setOpaque(false); return b; }
From source file:pl.otros.logview.api.gui.LogViewPanelWrapper.java
public void goToLiveMode() { JToolBar jToolBar = new JToolBar(); createFollowCheckBox();// w ww.j a v a 2s . c o m createPauseCheckBox(); createReadingProgressBar(); jToolBar.add(playTailing); jToolBar.add(follow); JButton clear = new JButton(new ClearLogTableAction(otrosApplication)); clear.setBorderPainted(false); jToolBar.add(clear); jToolBar.add(progressBar); logViewPanel.add(jToolBar, BorderLayout.NORTH); logViewPanel.getLogsMarkersPanel().setLayout(new BorderLayout()); TailingModeMarkersPanel markersPanel = new TailingModeMarkersPanel(logViewPanel.getDataTableModel()); logViewPanel.getLogsMarkersPanel().add(markersPanel); switchToContentView(); addRowAutoScroll(); }
From source file:pl.otros.logview.gui.LogViewPanelWrapper.java
public void goToLiveMode() { mode = Mode.Live;//from w w w.j av a2s .c o m JToolBar jToolBar = new JToolBar(); createFollowCheckBox(); createPauseCheckBox(); jToolBar.add(playTailing); jToolBar.add(follow); JButton clear = new JButton(new ClearLogTableAction(otrosApplication)); clear.setBorderPainted(false); jToolBar.add(clear); logViewPanel.add(jToolBar, BorderLayout.NORTH); logViewPanel.getLogsMarkersPanel().setLayout(new BorderLayout()); TailingModeMarkersPanel markersPanel = new TailingModeMarkersPanel(logViewPanel.getDataTableModel()); logViewPanel.getLogsMarkersPanel().add(markersPanel); switchToContentView(); addRowScroller(); }
From source file:savant.view.variation.swing.VariationModule.java
public VariationModule(VariationController vc) { super(new GridBagLayout()); controller = vc;/*from w w w . j a va 2 s . co m*/ // Toolbar shared by all panels. JToolBar tools = new JToolBar(); tools.setFloatable(false); rangeField = new JTextField(); rangeField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { String text = rangeField.getText(); try { Bookmark bm = new Bookmark(text, controller.getReference(), controller.getVisibleRange()); controller.setLocation(bm.getReference(), (Range) bm.getRange()); } catch (ParseException x) { DialogUtils.displayMessage(String.format("Unable to parse \"%s\" as a location.", text)); } } }); tools.add(rangeField); tools.addSeparator(); JButton zoomInButton = new JButton(); zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN)); zoomInButton.setBorderPainted(false); zoomInButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controller.zoomIn(); } }); tools.add(zoomInButton); JButton zoomOutButton = new JButton(); zoomOutButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT)); zoomOutButton.setBorderPainted(false); zoomOutButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controller.zoomOut(); } }); tools.add(zoomOutButton); tools.addSeparator(); JButton controlsButton = new JButton("Controls"); controlsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (controller.getTracks().length > 0) { new CaseControlDialog(controller).setVisible(true); frequencyPlot.repaint(); } else { Toolkit.getDefaultToolkit().beep(); } } }); tools.add(controlsButton); tabs = new JTabbedPane(); table = new RecordTable(new VariantTableModel(null)); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { controller.navigateToRecord(controller.getData().get(table.getSelectedRow())); } } }); tabs.addTab("Table", new JScrollPane(table)); map = new VariantMap(controller); map.addMouseWheelListener(wheelListener); LocationController.getInstance().addListener(new Listener<LocationChangedEvent>() { @Override public void handleEvent(LocationChangedEvent event) { map.repaint(); } }); JPanel mapPanel = populatePanel(map); tabs.addTab("Map", mapPanel); frequencyPlot = new AlleleFrequencyPlot(controller); frequencyPlot.addMouseWheelListener(wheelListener); JPanel frequencyPanel = populatePanel(frequencyPlot); tabs.addTab("Allele Frequency", frequencyPanel); JPanel ldPanel = new JPanel(); ldPanel.setLayout(new GridBagLayout()); ActionListener redrawForcer = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { ldPlot.repaint(); } }; JRadioButton dPrimeButton = new JRadioButton("D\u2032", true); dPrimeButton.setActionCommand("true"); dPrimeButton.addActionListener(redrawForcer); JRadioButton rSquaredButton = new JRadioButton("r\u00B2", false); rSquaredButton.setActionCommand("false"); rSquaredButton.addActionListener(redrawForcer); methodGroup = new ButtonGroup(); JPanel methodPanel = new JPanel(); methodPanel.setBorder(BorderFactory.createTitledBorder("Calculation Method")); methodPanel.add(dPrimeButton); methodGroup.add(dPrimeButton); methodPanel.add(rSquaredButton); methodGroup.add(rSquaredButton); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; gbc.weighty = 0.0; ldPanel.add(methodPanel, gbc); ldPlot = new LDPlot(controller); JPanel lowerLDPanel = populatePanel(ldPlot); gbc.weighty = 1.0; ldPanel.add(lowerLDPanel, gbc); tabs.addTab("LD Plot", ldPanel); gbc.weighty = 0.0; add(tools, gbc); // Create the informative cards, but don't use them. messageLabel = new JLabel(); messageLabel.setFont(MESSAGE_FONT); messagePanel = populatePanel(messageLabel); progressPanel = new ProgressPanel(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { controller.cancelDataRequests(); } }); showCard(tabs, null); }
From source file:se.cambio.cds.gdl.editor.view.panels.ListPanel.java
private void init() { this.setLayout(new BorderLayout()); this.setBorder(BorderFactory.createTitledBorder(_title)); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS)); JButton addButton = new JButton(GDLEditorImageUtil.ADD_ICON); addButton.setContentAreaFilled(false); addButton.setPreferredSize(new Dimension(16, 16)); addButton.setBorderPainted(false); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String value = JOptionPane.showInputDialog(EditorManager.getActiveEditorWindow(), _title, ""); if (value != null) { DefaultListModel dlm = ((DefaultListModel) getJList().getModel()); dlm.addElement(value);//from w w w . j a v a 2s.c om updateListModel(dlm); } } }); JButton deleteButton = new JButton(GDLEditorImageUtil.DELETE_ICON); deleteButton.setContentAreaFilled(false); deleteButton.setPreferredSize(new Dimension(16, 16)); deleteButton.setBorderPainted(false); deleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int index = getJList().getSelectedIndex(); if (index >= 0) { DefaultListModel dlm = ((DefaultListModel) getJList().getModel()); dlm.removeElementAt(index); updateListModel(dlm); } } }); buttonPanel.add(addButton); buttonPanel.add(deleteButton); this.add(buttonPanel, BorderLayout.WEST); this.add(getJList(), BorderLayout.CENTER); }
From source file:snepsui.Interface.DrawNetwork.java
/** * Initializes the components in the DrawNetwork panel *//*w ww . ja va2 s . co m*/ private void initGUI() { nodesList = new LinkedList<Node>(); molNodes = new Hashtable<String, CaseFrame>(); builtMolNodes = new Hashtable<String, Node>(); this.setPreferredSize(new Dimension(815, 600)); graph = new DirectedOrderedSparseMultigraph<String, String>(); this.layout = new StaticLayout<String, String>(graph, new Dimension(700, 450)); shape = new Transformer<String, Integer>() { public Integer transform(String vertex) { int stringLength = 0; if (molNodes.containsKey(vertex)) { stringLength = 3; } else { for (Node node : nodesList) { if (vertex.equals(node.getIdentifier())) { stringLength = node.getIdentifier().length(); } } } return stringLength; } }; vertexPaint = new Transformer<String, Paint>() { public Paint transform(String vertex) { if (molNodes.containsKey(vertex)) { if (builtMolNodes.containsKey(vertex)) { Node node = builtMolNodes.get(vertex); if (node.getClass().getSimpleName().equals("PatternNode")) { return Color.blue; } else if (node.getClass().getSimpleName().equals("ClosedNode")) { return Color.yellow; } } else return Color.white; } else { for (Node node : nodesList) { if (node.getIdentifier().equals(vertex)) { if (node.getClass().getSimpleName().equals("BaseNode")) { return Color.green; } else if (node.getClass().getSimpleName().equals("VariableNode")) { return Color.gray; } else if (node.getClass().getSimpleName().equals("PatternNode")) { return Color.blue; } else if (node.getClass().getSimpleName().equals("ClosedNode")) { return Color.yellow; } else { return Color.magenta; } } } } return Color.white; } }; edgeLabel = new Transformer<String, String>() { public String transform(String edge) { String result = ""; if (edge.isEmpty()) graph.removeEdge(""); vv.repaint(); try { result = edge.substring(0, edge.indexOf(":")); } catch (StringIndexOutOfBoundsException e) { } return result; } }; VertexShapeSizeAspect<String> vssa = new VertexShapeSizeAspect<String>(graph, shape); vv = new VisualizationViewer<String, String>(layout, new Dimension(700, 470)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(MapTransformer.<String, String>getInstance( LazyMap.<String, String>decorate(new HashMap<String, String>(), new ToStringLabeller<String>()))); vv.getRenderContext().setEdgeLabelTransformer(MapTransformer.<String, String>getInstance( LazyMap.<String, String>decorate(new HashMap<String, String>(), new ToStringLabeller<String>()))); vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer()); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); vv.getRenderContext().setVertexShapeTransformer(vssa); vv.getRenderContext() .setEdgeLabelClosenessTransformer(new ConstantDirectionalEdgeValueTransformer(0.5, 0.5)); vv.getRenderContext().setEdgeLabelTransformer(edgeLabel); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { point = e.getPoint(); } public void mouseReleased(MouseEvent e) { vv.repaint(); } }); vssa.setScaling(true); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); this.add(panel); Factory<String> vertexFactory = new VertexFactory(); Factory<String> edgeFactory = new EdgeFactory(); final EditingModalGraphMouse<String, String> graphMouse = new EditingModalGraphMouse<String, String>( vv.getRenderContext(), vertexFactory, edgeFactory); graphMouse.add(new CustomEditingPopupGraphMousePlugin<String>(vertexFactory, edgeFactory)); graphMouse.remove(graphMouse.getPopupEditingPlugin()); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); graphMouse.setMode(ModalGraphMouse.Mode.EDITING); final ScalingControl scaler = new CrossoverScalingControl(); vv.scaleToLayout(scaler); String path = "src/snepsui/Interface/resources/icons/"; JButton plus = new JButton(); plus.setIcon(new ImageIcon(path + "zoom_in.png")); plus.setSize(18, 18); plus.setFocusPainted(false); plus.setBorderPainted(false); plus.setContentAreaFilled(false); plus.setMargin(new Insets(0, 0, 0, 0)); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton(); minus.setIcon(new ImageIcon(path + "zoom_out.png")); minus.setSize(18, 18); minus.setFocusPainted(false); minus.setBorderPainted(false); minus.setContentAreaFilled(false); minus.setMargin(new Insets(0, 0, 0, 0)); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 2)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JButton colors = new JButton(new ImageIcon(path + "colors.png")); colors.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(getRootPane(), new NodeColors()); } }); JButton infoButton = new JButton(new ImageIcon(path + "info.png")); infoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(vv, instructions, "Instructions", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/snepsui/Interface/resources/icons/info.png")); } }); JButton resetbutton = new JButton(new ImageIcon(path + "refresh.png")); resetbutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ImageIcon icon = new ImageIcon("src/snepsui/Interface/resources/icons/info.png"); int result = JOptionPane.showConfirmDialog(vv, "Are you sure you want to reset the drawing area?", "Reset", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, icon); if (result == JOptionPane.YES_OPTION) { builtMolNodes.clear(); molNodes.clear(); nodesList.clear(); LinkedList<String> vertexList = new LinkedList<String>(); Collection<String> vertices = graph.getVertices(); for (String vertex : vertices) { vertexList.add(vertex); } for (String item : vertexList) { graph.removeVertex(item); } vv.repaint(); } } }); JLabel caseframeLabel = new JLabel("Case Frames"); DefaultComboBoxModel caseframeComboBoxModel = new DefaultComboBoxModel( new String[] { "define-caseframe", "undefine-caseframe" }); caseframeComboBox = new JComboBox(); caseframeComboBox.setModel(caseframeComboBoxModel); caseframeComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addCaseFrameCommands(e); } }); JLabel relationsLabel = new JLabel("Relations"); DefaultComboBoxModel relationsComboBoxModel = new DefaultComboBoxModel( new String[] { "define", "undefine" }); relationsComboBox = new JComboBox(); relationsComboBox.setModel(relationsComboBoxModel); relationsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addRelationCommands(e); } }); JPanel options = new JPanel(new GridLayout(3, 1)); options.add(infoButton); options.add(resetbutton); options.add(colors); this.add(options, BorderLayout.EAST); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); controls.add(relationsLabel); controls.add(relationsComboBox); controls.add(caseframeLabel); controls.add(caseframeComboBox); JComboBox modeBox = graphMouse.getModeComboBox(); controls.add(modeBox); this.add(controls, BorderLayout.SOUTH); }
From source file:util.ui.UiUtilities.java
/** * Gibt einen Button mit Icon und Schrift zurck, der so initialisiert ist, * da man ihn gut fr Symbolleisten nutzen kann (Rahmen nur bei Rollover * sichtbar usw.)./*w ww . j a v a2 s. c om*/ * <P> * Wenn text und iconDateiname angegeben sind, dann wird text als TooltipText * gesetzt. * * @param text * Der Text des Buttons (Kann null sein, wenn der Button keinen Text * enthalten soll) * @param icon * Das Icon des Buttons (Kann ebenfalls null sein, wenn der Button * kein Icon enthalten soll). * @return button */ public static JButton createToolBarButton(String text, Icon icon) { final JButton btn; if (icon == null) { btn = new JButton(text); } else { btn = new JButton(icon); btn.setToolTipText(text); btn.setBorderPainted(false); btn.setMargin(ZERO_INSETS); btn.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { if (btn.isEnabled()) { btn.setBorderPainted(true); } } @Override public void mouseExited(MouseEvent e) { btn.setBorderPainted(false); } }); } btn.setFocusPainted(false); return btn; }