List of usage examples for javax.swing JButton setContentAreaFilled
@BeanProperty(visualUpdate = true, description = "Whether the button should paint the content area or leave it transparent.") public void setContentAreaFilled(boolean b)
contentAreaFilled
property. From source file:org.richie.codeGen.ui.GenAndPreviewUI.java
/** * ??/*from w w w . j a va 2 s .co m*/ * * @param fileName * @param fileContent */ private void addPreviewTablePanel(String fileName, String fileContent) { final JScrollPane content = new JScrollPane(); JTextArea viewTextArea = new JTextArea(); viewTextArea.setText(fileContent); content.setViewportView(viewTextArea); JPanel tab = new JPanel(); tab.setOpaque(false); JLabel tabLabel = new JLabel(fileName); ImageIcon closeXIcon = new ImageIcon(ClassLoader.getSystemResource("resources/images/close.gif")); JButton tabCloseButton = new JButton(closeXIcon); tabCloseButton.setToolTipText("close"); tabCloseButton.setBorder(null); tabCloseButton.setContentAreaFilled(false); tabCloseButton.setPreferredSize(new Dimension(closeXIcon.getIconWidth(), closeXIcon.getIconHeight())); tabCloseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int closeTabNumber = mainPanel.indexOfComponent(content); mainPanel.removeTabAt(closeTabNumber); } }); tab.add(tabLabel, BorderLayout.WEST); tab.add(tabCloseButton, BorderLayout.EAST); mainPanel.addTab(null, content); mainPanel.setTabComponentAt(mainPanel.getTabCount() - 1, tab); mainPanel.setSelectedComponent(content); }
From source file:org.tinymediamanager.ui.dialogs.ImageChooserDialog.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private void addImage(BufferedImage originalImage, final MediaArtwork artwork) { Point size = null;//from www. j ava2s. 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(); }
From source file:org.tinymediamanager.ui.MainWindow.java
/** * Create the application./*w ww. ja va2 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: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);/*from ww w . j a v a 2 s . c o m*/ 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); 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 *///www .j a va 2 s . c om 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:wsattacker.sso.openid.attacker.gui.MainGui.java
private void removeBackgroundFromButton(JButton button) { button.setHorizontalAlignment(SwingConstants.LEFT); button.setBorder(null);/*from w w w. j av a2 s. com*/ button.setBorderPainted(false); button.setContentAreaFilled(false); }