List of usage examples for javax.swing Icon getIconHeight
int getIconHeight();
From source file:com.sshtools.appframework.ui.SshToolsApplication.java
public void setLookAndFeel(UIManager.LookAndFeelInfo laf) { if (laf != null) { log.info("Setting Look and Feel to " + laf.getClassName()); try {/*from www . j a va 2 s .c o m*/ @SuppressWarnings("unchecked") LookAndFeel l = createLookAndFeel((Class<LookAndFeel>) Class.forName(laf.getClassName())); UIManager.setLookAndFeel(l); Icon checkIcon = UIManager.getIcon("CheckBoxMenuItem.checkIcon"); Icon radioIcon = UIManager.getIcon("RadioButtonMenuItem.checkIcon"); UIManager.put("MenuItem.checkIcon", new EmptyIcon( Math.max(checkIcon.getIconWidth(), radioIcon.getIconWidth()), checkIcon.getIconHeight())); UIManager.put("Menu.checkIcon", new EmptyIcon( Math.max(checkIcon.getIconWidth(), radioIcon.getIconWidth()), checkIcon.getIconHeight())); for (SshToolsApplicationContainer container : containers) { container.updateUI(); } for (OptionsTab tab : additionalOptionsTabs) { SwingUtilities.updateComponentTreeUI(tab.getTabComponent()); } } catch (Throwable t) { /* DEBUG */t.printStackTrace(); } } }
From source file:be.ac.ua.comp.scarletnebula.gui.windows.GUI.java
private void addToolbar() { final JToolBar toolbar = new JToolBar(); final Icon addIcon = Utils.icon("add16.png"); final JButton addButton = new JButton(addIcon); addButton.addActionListener(new ActionListener() { @Override/*from www . j a v a 2s. com*/ public void actionPerformed(final ActionEvent e) { startAddServerWizard(); } }); addButton.setBounds(10, 10, addIcon.getIconWidth(), addIcon.getIconHeight()); final Icon refreshIcon = Utils.icon("refresh16.png"); final JButton refreshButton = new JButton(refreshIcon); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { refreshSelectedServers(); } }); refreshButton.setBounds(10, 10, refreshIcon.getIconWidth(), refreshIcon.getIconHeight()); final Icon searchIcon = Utils.icon("search16.png"); final JButton searchButton = new JButton(searchIcon); searchButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { showFilter(); } }); searchButton.setBounds(10, 10, searchIcon.getIconWidth(), searchIcon.getIconHeight()); toolbar.add(addButton); toolbar.add(refreshButton); toolbar.add(searchButton); toolbar.setFloatable(false); add(toolbar, BorderLayout.PAGE_START); }
From source file:edu.uci.ics.jung.visualization.PluggableRenderer.java
/** * Paint <code>v</code>'s icon on <code>g</code> at <code>(x,y)</code>. *//*from www . j a v a 2 s. co m*/ public void paintIconForVertex(Graphics g, Vertex v, int x, int y) { Icon icon = vertexIconFunction.getIcon(v); if (icon == null) { Shape s = AffineTransform.getTranslateInstance(x, y) .createTransformedShape(getVertexShapeFunction().getShape(v)); paintShapeForVertex((Graphics2D) g, v, s); } else { int xLoc = x - icon.getIconWidth() / 2; int yLoc = y - icon.getIconHeight() / 2; icon.paintIcon(screenDevice, g, xLoc, yLoc); } }
From source file:display.containers.FileManager.java
/** Update the table on the EDT */ private void setTableData(final File[] files) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (fileTableModel == null) { fileTableModel = new FileTableModel(table); table.setModel(fileTableModel); }/*from ww w.j a v a2s.co m*/ table.getSelectionModel().removeListSelectionListener(listSelectionListener); fileTableModel.setFiles(files); table.getSelectionModel().addListSelectionListener(listSelectionListener); if (!cellSizesSet && files != null && files.length > 0) { Icon icon = fileSystemView.getSystemIcon(files[0]); // size adjustment to better account for icons table.setRowHeight(icon.getIconHeight() + rowIconPadding); setColumnWidth(0, -1); // setColumnWidth(3,70); // table.getColumnModel().getColumn(3).setMaxWidth(60); cellSizesSet = true; } } }); }
From source file:es.emergya.ui.plugins.AdminPanel.java
public AdminPanel(String t, Icon icon, Option myself, boolean canCreateNew, boolean canDelete) { super();/*from w w w .j a v a 2 s .c o m*/ setCanCreateNew(canCreateNew); setCanDelete(canDelete); setLayout(new SpringLayout()); this.father = myself; setBackground(Color.WHITE); // Titulo con icono JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); title = new JLabel(t); title.setIcon(icon); title.setFont(LogicConstants.deriveBoldFont(12f)); title.setBorder(new EmptyBorder(0, 10, 0, 10)); titlePanel.add(title); titlePanel.setOpaque(false); add(titlePanel); Dimension d = titlePanel.getSize(); if (icon != null) d.height = icon.getIconHeight(); titlePanel.setMaximumSize(d); // Controles de "nuevo" "seleccionar todos" etc... JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEADING)); controls.setOpaque(false); final boolean femenino = t.indexOf("atrulla") != -1 || t.indexOf("apa") != -1 || t.indexOf("lota") != -1 || t.indexOf("encia") != -1; if (getCanCreateNew()) { if (femenino) { newButton = new JButton("Nueva", getIcon("button_nuevo")); } else { newButton = new JButton("Nuevo", getIcon("button_nuevo")); } controls.add(newButton); } if (getCanDelete()) { JButton selectAll = new JButton(((femenino) ? "Seleccionar Todas" : "Seleccionar Todos"), getIcon("button_selectall")); selectAll.addActionListener(this); controls.add(selectAll); deselectAll = new JButton(((femenino) ? "Deseleccionar Todas" : "Deseleccionar Todos"), getIcon("button_unselectall")); deselectAll.addActionListener(this); controls.add(deselectAll); JButton deleteAll = new JButton(((femenino) ? "Eliminar Seleccionadas" : "Eliminar Seleccionados"), getIcon("button_delall")); deleteAll.addActionListener(this); controls.add(deleteAll); } d = controls.getSize(); controls.setMaximumSize(d); add(controls); // Tabla tablePanel = new JPanel(new BorderLayout()); tablePanel.setOpaque(false); add(tablePanel); SpringUtilities.makeCompactGrid(this, 3, 1, 0, 0, 0, 0); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java
/** * Notification that the Map was received. * @param map icon of the map that was generated *//*from w ww . j a v a 2s .c o m*/ protected void mapImageReceived(final Icon map) { JStatusBar statusBar = UIRegistry.getStatusBar(); statusBar.setProgressDone(WorkbenchTask.WORKBENCH); statusBar.setText(""); if (map != null) { UIHelper.positionFrameRelativeToTopFrame(mapFrame); mapFrame.setVisible(true); mapImageLabel.setIcon(map); //showMapBtn.setEnabled(true); // is the map really skinny? int ht = map.getIconHeight(); int wd = map.getIconWidth(); if (ht < 20 && wd > 100 || ht > 100 && wd < 20) { statusBar.setWarningMessage("WB_THIN_MAP_WARNING"); } } }
From source file:org.eobjects.datacleaner.panels.OpenAnalysisJobPanel.java
public OpenAnalysisJobPanel(final FileObject file, final AnalyzerBeansConfiguration configuration, final OpenAnalysisJobActionListener openAnalysisJobActionListener) { super(WidgetUtils.BG_COLOR_LESS_BRIGHT, WidgetUtils.BG_COLOR_LESS_BRIGHT); _file = file;// w w w. ja va2 s . co m _openAnalysisJobActionListener = openAnalysisJobActionListener; setLayout(new BorderLayout()); setBorder(WidgetUtils.BORDER_LIST_ITEM); final AnalysisJobMetadata metadata = getMetadata(configuration); final String jobName = metadata.getJobName(); final String jobDescription = metadata.getJobDescription(); final String datastoreName = metadata.getDatastoreName(); final boolean isDemoJob = isDemoJob(metadata); final DCPanel labelListPanel = new DCPanel(); labelListPanel.setLayout(new VerticalLayout(4)); labelListPanel.setBorder(new EmptyBorder(4, 4, 4, 0)); final String title; final String filename = file.getName().getBaseName(); if (Strings.isNullOrEmpty(jobName)) { final String extension = FileFilters.ANALYSIS_XML.getExtension(); if (filename.toLowerCase().endsWith(extension)) { title = filename.substring(0, filename.length() - extension.length()); } else { title = filename; } } else { title = jobName; } final JButton titleButton = new JButton(title); titleButton.setFont(WidgetUtils.FONT_HEADER1); titleButton.setForeground(WidgetUtils.BG_COLOR_BLUE_MEDIUM); titleButton.setHorizontalAlignment(SwingConstants.LEFT); titleButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, WidgetUtils.BG_COLOR_MEDIUM)); titleButton.setToolTipText("Open job"); titleButton.setOpaque(false); titleButton.setMargin(new Insets(0, 0, 0, 0)); titleButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); titleButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isDemoDatastoreConfigured(datastoreName, configuration)) { _openAnalysisJobActionListener.openFile(_file); } } }); final JButton executeButton = new JButton(executeIcon); executeButton.setOpaque(false); executeButton.setToolTipText("Execute job directly"); executeButton.setMargin(new Insets(0, 0, 0, 0)); executeButton.setBorderPainted(false); executeButton.setHorizontalAlignment(SwingConstants.RIGHT); executeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isDemoDatastoreConfigured(datastoreName, configuration)) { final ImageIcon executeIconLarge = ImageManager.get().getImageIcon(IconUtils.ACTION_EXECUTE); final String question = "Are you sure you want to execute the job\n'" + title + "'?"; final int choice = JOptionPane.showConfirmDialog(null, question, "Execute job?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, executeIconLarge); if (choice == JOptionPane.YES_OPTION) { final Injector injector = _openAnalysisJobActionListener.openAnalysisJob(_file); if (injector != null) { final ResultWindow resultWindow = injector.getInstance(ResultWindow.class); resultWindow.open(); resultWindow.startAnalysis(); } } } } }); final DCPanel titlePanel = new DCPanel(); titlePanel.setLayout(new BorderLayout()); titlePanel.add(DCPanel.around(titleButton), BorderLayout.CENTER); titlePanel.add(executeButton, BorderLayout.EAST); labelListPanel.add(titlePanel); if (!Strings.isNullOrEmpty(jobDescription)) { String desc = StringUtils.replaceWhitespaces(jobDescription, " "); desc = StringUtils.replaceAll(desc, " ", " "); final JLabel label = new JLabel(desc); label.setFont(WidgetUtils.FONT_SMALL); labelListPanel.add(label); } final Icon icon; { if (!StringUtils.isNullOrEmpty(datastoreName)) { final JLabel label = new JLabel(" " + datastoreName); label.setFont(WidgetUtils.FONT_SMALL); labelListPanel.add(label); final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(datastoreName); if (isDemoJob) { icon = demoBadgeIcon; } else { icon = IconUtils.getDatastoreSpecificAnalysisJobIcon(datastore); } } else { icon = ImageManager.get().getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_LARGE); } } final JLabel iconLabel = new JLabel(icon); iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight())); add(iconLabel, BorderLayout.WEST); add(labelListPanel, BorderLayout.CENTER); }
From source file:org.executequery.gui.browser.TableDataTab.java
private Object setTableResultsPanel(DatabaseObject databaseObject) { tableDataChanges.clear();//from w w w .j a va2 s . c o m primaryKeyColumns.clear(); foreignKeyColumns.clear(); this.databaseObject = databaseObject; try { initialiseModel(); tableModel.setCellsEditable(false); tableModel.removeTableModelListener(this); if (isDatabaseTable()) { DatabaseTable databaseTable = asDatabaseTable(); if (databaseTable.hasPrimaryKey()) { primaryKeyColumns = databaseTable.getPrimaryKeyColumnNames(); canEditTableLabel.setText("This table has a primary key(s) and data may be edited here"); } if (databaseTable.hasForeignKey()) { foreignKeyColumns = databaseTable.getForeignKeyColumnNames(); } if (primaryKeyColumns.isEmpty()) { canEditTableLabel.setText("This table has no primary keys defined and is not editable here"); } canEditTableNotePanel.setVisible(alwaysShowCanEditNotePanel); } if (!isDatabaseTable()) { canEditTableNotePanel.setVisible(false); } Log.debug("Retrieving data for table - " + databaseObject.getName()); ResultSet resultSet = databaseObject.getData(true); tableModel.createTable(resultSet); if (table == null) { createResultSetTable(); } tableModel.setNonEditableColumns(primaryKeyColumns); TableSorter sorter = new TableSorter(tableModel); table.setModel(sorter); sorter.setTableHeader(table.getTableHeader()); if (isDatabaseTable()) { SortableHeaderRenderer renderer = new SortableHeaderRenderer(sorter) { private ImageIcon primaryKeyIcon = GUIUtilities .loadIcon(BrowserConstants.PRIMARY_COLUMNS_IMAGE); private ImageIcon foreignKeyIcon = GUIUtilities .loadIcon(BrowserConstants.FOREIGN_COLUMNS_IMAGE); @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) super.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column); Icon keyIcon = iconForValue(value); if (keyIcon != null) { Icon icon = renderer.getIcon(); if (icon != null) { BufferedImage image = new BufferedImage( icon.getIconWidth() + keyIcon.getIconWidth() + 2, Math.max(keyIcon.getIconHeight(), icon.getIconHeight()), BufferedImage.TYPE_INT_ARGB); Graphics graphics = image.getGraphics(); keyIcon.paintIcon(null, graphics, 0, 0); icon.paintIcon(null, graphics, keyIcon.getIconWidth() + 2, 5); setIcon(new ImageIcon(image)); } else { setIcon(keyIcon); } } return renderer; } private ImageIcon iconForValue(Object value) { if (value != null) { String name = value.toString(); if (primaryKeyColumns.contains(name)) { return primaryKeyIcon; } else if (foreignKeyColumns.contains(name)) { return foreignKeyIcon; } } return null; } }; sorter.setTableHeaderRenderer(renderer); } table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); scroller.getViewport().add(table); removeAll(); add(canEditTableNotePanel, canEditTableNoteConstraints); add(scroller, scrollerConstraints); if (displayRowCount && SystemProperties.getBooleanProperty("user", "browser.query.row.count")) { add(rowCountPanel, rowCountPanelConstraints); rowCountField.setText(String.valueOf(sorter.getRowCount())); } } catch (DataSourceException e) { if (!cancelled) { addErrorLabel(e); } else { addCancelledLabel(); } } finally { tableModel.addTableModelListener(this); } setTableProperties(); validate(); repaint(); return "done"; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.OriginalMetadataComponent.java
/** Initializes the components. */ private void initComponents() { IconManager icons = IconManager.getInstance(); Icon icon = icons.getIcon(IconManager.DOWNLOAD); downloadButton = new JButton(icon); downloadButton.setBackground(UIUtilities.BACKGROUND_COLOR); downloadButton.setOpaque(false);// w ww .j a v a 2 s . c om UIUtilities.unifiedButtonLookAndFeel(downloadButton); downloadButton.setToolTipText("Download the metadata file."); downloadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { download(); } }); toolBar = buildToolBar(); toolBar.setBackground(UIUtilities.BACKGROUND_COLOR); JXBusyLabel label = new JXBusyLabel(new Dimension(icon.getIconWidth(), icon.getIconHeight())); label.setBackground(UIUtilities.BACKGROUND_COLOR); label.setBusy(true); JPanel p = new JPanel(); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.add(label); p.add(Box.createHorizontalStrut(5)); JLabel l = new JLabel("Loading metadata"); l.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(l); statusBar = UIUtilities.buildComponentPanel(p); statusBar.setBackground(UIUtilities.BACKGROUND_COLOR); setBackground(UIUtilities.BACKGROUND_COLOR); setLayout(new BorderLayout(0, 0)); add(statusBar, BorderLayout.NORTH); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java
/** * Helper method to create the tool bar hosting the management items. * // w w w . j ava 2 s . c om * @return See above. */ private JComponent createManagementBar() { bar = new JToolBar(); bar.setFloatable(false); bar.setRollover(true); bar.setBorder(null); JToggleButton button = new JToggleButton(controller.getAction(TreeViewerControl.INSPECTOR)); button.setSelected(true); bar.add(button); button = new JToggleButton(controller.getAction(TreeViewerControl.METADATA)); button.setSelected(true); bar.add(button); JButton b = new JButton(controller.getAction(TreeViewerControl.BROWSE)); UIUtilities.unifiedButtonLookAndFeel(b); bar.add(b); switch (TreeViewerAgent.runAsPlugin()) { case TreeViewer.IMAGE_J: b = UIUtilities.formatButtonFromAction(controller.getAction(TreeViewerControl.VIEW)); UIUtilities.unifiedButtonLookAndFeel(b); b.addMouseListener(new MouseAdapter() { /** * Displays the menu when the user releases the mouse. * @see MouseListener#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent e) { controller.showMenu(TreeViewer.VIEW_MENU, (JComponent) e.getSource(), e.getPoint()); } }); bar.add(b); break; default: b = new JButton(controller.getAction(TreeViewerControl.VIEW)); UIUtilities.unifiedButtonLookAndFeel(b); bar.add(b); } bar.add(new JSeparator(JSeparator.VERTICAL)); //Now register the agent if any TaskBar tb = TreeViewerAgent.getRegistry().getTaskBar(); List<JComponent> l = tb.getToolBarEntries(TaskBar.AGENTS); if (l != null) { Iterator<JComponent> i = l.iterator(); JComponent comp; while (i.hasNext()) { comp = i.next(); UIUtilities.unifiedButtonLookAndFeel(comp); bar.add(comp); } bar.add(new JSeparator(JSeparator.VERTICAL)); } fullScreen = new JToggleButton(controller.getAction(TreeViewerControl.FULLSCREEN)); fullScreen.setSelected(model.isFullScreen()); //bar.add(fullScreen); if (TreeViewerAgent.isAdministrator()) { b = new JButton(controller.getAction(TreeViewerControl.UPLOAD_SCRIPT)); UIUtilities.unifiedButtonLookAndFeel(b); bar.add(b); } TreeViewerAction a = controller.getAction(TreeViewerControl.AVAILABLE_SCRIPTS); b = new JButton(a); Icon icon = b.getIcon(); Dimension d = new Dimension(UIUtilities.DEFAULT_ICON_WIDTH, UIUtilities.DEFAULT_ICON_HEIGHT); if (icon != null) d = new Dimension(icon.getIconWidth(), icon.getIconHeight()); busyLabel = new JXBusyLabel(d); busyLabel.setVisible(true); b.addMouseListener((RunScriptAction) a); UIUtilities.unifiedButtonLookAndFeel(b); scriptButton = b; bar.add(b); index = bar.getComponentCount() - 1; bar.add(new JSeparator(JSeparator.VERTICAL)); MouseAdapter adapter = new MouseAdapter() { /** * Shows the menu corresponding to the display mode. */ public void mousePressed(MouseEvent me) { createGroupsAndUsersMenu((Component) me.getSource(), me.getPoint()); } }; a = controller.getAction(TreeViewerControl.SWITCH_USER); IconManager icons = IconManager.getInstance(); menuButton = new JButton(icons.getIcon(IconManager.FILTER_MENU)); menuButton.setVisible(true); menuButton.setText(GROUP_DISPLAY_TEXT); menuButton.setHorizontalTextPosition(SwingConstants.LEFT); menuButton.addMouseListener(adapter); bar.add(menuButton); setPermissions(); return bar; }