List of usage examples for javax.swing JLabel setIcon
@BeanProperty(preferred = true, visualUpdate = true, description = "The icon this component will display.") public void setIcon(Icon icon)
From source file:org.thelq.stackexchange.dbimport.gui.GUI.java
/** * Update the list of locations/*from ww w . ja v a2 s . co m*/ */ protected void updateLocations() { locationsBuilder.getPanel().removeAll(); for (final DumpContainer curContainer : controller.getDumpContainers()) { //Initialize components if (curContainer.getGuiHeader() == null) { String longLocation = Utils.getLongLocation(curContainer); JLabel headerLabel = new JLabel(longLocation); headerLabel.setToolTipText(longLocation); headerLabel.setIcon(UIManager.getIcon("Tree.collapsedIcon")); JPopupMenu popupMenu = new JPopupMenu(); JMenuItem deleteItem = new JMenuItem("Delete"); deleteItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { log.info("Removing " + curContainer.getType() + " " + curContainer.getLocation()); controller.getDumpContainers().remove(curContainer); updateLocations(); } }); popupMenu.add(deleteItem); headerLabel.setComponentPopupMenu(popupMenu); curContainer.setGuiHeader(headerLabel); //Handlers headerLabel.addMouseListener(new MouseAdapter() { boolean visible = true; @Override public void mouseClicked(MouseEvent e) { //Update labels visible = !visible; for (DumpEntry curEntry : curContainer.getEntries()) { curEntry.getGuiName().setVisible(visible); curEntry.getGuiSize().setVisible(visible); curEntry.getGuiLog().setVisible(visible); if (curEntry.getGuiSeparator() != null) curEntry.getGuiSeparator().setVisible(visible); } //Change icon if (visible) curContainer.getGuiHeader().setIcon(UIManager.getIcon("Tree.expandedIcon")); else curContainer.getGuiHeader().setIcon(UIManager.getIcon("Tree.collapsedIcon")); locationsPane.revalidate(); } }); } if (curContainer.getGuiTablePrefix() == null) { JTextField headerPrefix = new JTextField(6); curContainer.setGuiTablePrefix(headerPrefix); headerPrefix.setText(Utils.genTablePrefix(curContainer.getName())); if (StringUtils.isBlank(headerPrefix.getText())) log.warn("Unable to generate a table prefix for {}", curContainer.getLocation()); } //Start adding to panel locationsBuilder.leadingColumnOffset(0); locationsBuilder.append(curContainer.getGuiHeader(), 7); locationsBuilder.append(curContainer.getGuiTablePrefix()); locationsBuilder.nextLine(); locationsBuilder.leadingColumnOffset(2); Iterator<DumpEntry> entriesItr = curContainer.getEntries().iterator(); while (entriesItr.hasNext()) { DumpEntry curEntry = entriesItr.next(); if (curEntry.getGuiName() == null) curEntry.setGuiName(new JLabel(curEntry.getName())); locationsBuilder.append(curEntry.getGuiName()); if (curEntry.getGuiSize() == null) curEntry.setGuiSize(new JLabel(sizeInMegabytes(curEntry.getSizeBytes()))); locationsBuilder.append(curEntry.getGuiSize()); if (curEntry.getGuiLog() == null) curEntry.setGuiLog(new JLabel("Waiting...")); locationsBuilder.append(curEntry.getGuiLog(), 3); locationsBuilder.nextLine(); if (entriesItr.hasNext()) { if (curEntry.getGuiSeparator() == null) curEntry.setGuiSeparator(new JSeparator()); locationsBuilder.append(curEntry.getGuiSeparator(), 7); locationsBuilder.nextLine(); } } } locationsPane.validate(); }
From source file:org.tinymediamanager.ui.tvshows.TvShowPanel.java
/** * Instantiates a new tv show panel.//w w w . j a v a 2 s . c o m */ public TvShowPanel() { super(); treeModel = new TvShowTreeModel(tvShowList.getTvShows()); tvShowSeasonSelectionModel = new TvShowSeasonSelectionModel(); tvShowEpisodeSelectionModel = new TvShowEpisodeSelectionModel(); // build menu menu = new JMenu(BUNDLE.getString("tmm.tvshows")); //$NON-NLS-1$ JFrame mainFrame = MainWindow.getFrame(); JMenuBar menuBar = mainFrame.getJMenuBar(); menuBar.add(menu); setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); JSplitPane splitPane = new JSplitPane(); splitPane.setContinuousLayout(true); add(splitPane, "2, 2, fill, fill"); JPanel panelTvShowTree = new JPanel(); splitPane.setLeftComponent(panelTvShowTree); panelTvShowTree.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("3px:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); textField = EnhancedTextField.createSearchTextField(); panelTvShowTree.add(textField, "4, 1, right, bottom"); textField.setColumns(12); textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(final DocumentEvent e) { applyFilter(); } @Override public void removeUpdate(final DocumentEvent e) { applyFilter(); } @Override public void changedUpdate(final DocumentEvent e) { applyFilter(); } public void applyFilter() { TvShowTreeModel filteredModel = (TvShowTreeModel) tree.getModel(); if (StringUtils.isNotBlank(textField.getText())) { filteredModel.setFilter(SearchOptions.TEXT, textField.getText()); } else { filteredModel.removeFilter(SearchOptions.TEXT); } filteredModel.filter(tree); } }); final JToggleButton btnFilter = new JToggleButton(IconManager.FILTER); btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$ panelTvShowTree.add(btnFilter, "6, 1, default, bottom"); JScrollPane scrollPane = new JScrollPane(); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); panelTvShowTree.add(scrollPane, "2, 3, 5, 1, fill, fill"); JToolBar toolBar = new JToolBar(); toolBar.setRollover(true); toolBar.setFloatable(false); toolBar.setOpaque(false); panelTvShowTree.add(toolBar, "2, 1"); // toolBar.add(actionUpdateDatasources); final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH); // temp fix for size of the button buttonUpdateDatasource.setText(" "); buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT); // buttonScrape.setMargin(new Insets(2, 2, 2, 24)); buttonUpdateDatasource.setSplitWidth(18); buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$ buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() { public void buttonClicked(ActionEvent e) { actionUpdateDatasources.actionPerformed(e); } public void splitButtonClicked(ActionEvent e) { // build the popupmenu on the fly buttonUpdateDatasource.getPopupMenu().removeAll(); buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateDatasources2)); buttonUpdateDatasource.getPopupMenu().addSeparator(); for (String ds : TvShowModuleManager.SETTINGS.getTvShowDataSource()) { buttonUpdateDatasource.getPopupMenu() .add(new JMenuItem(new TvShowUpdateSingleDatasourceAction(ds))); } buttonUpdateDatasource.getPopupMenu().addSeparator(); buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateTvShow)); buttonUpdateDatasource.getPopupMenu().pack(); } }); JPopupMenu popup = new JPopupMenu("popup"); buttonUpdateDatasource.setPopupMenu(popup); toolBar.add(buttonUpdateDatasource); JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH); // temp fix for size of the button buttonScrape.setText(" "); buttonScrape.setHorizontalAlignment(JButton.LEFT); buttonScrape.setSplitWidth(18); buttonScrape.setToolTipText(BUNDLE.getString("tvshow.scrape.selected")); //$NON-NLS-1$ // register for listener buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() { @Override public void buttonClicked(ActionEvent e) { actionScrape.actionPerformed(e); } @Override public void splitButtonClicked(ActionEvent e) { } }); popup = new JPopupMenu("popup"); JMenuItem item = new JMenuItem(actionScrape2); popup.add(item); // item = new JMenuItem(actionScrapeUnscraped); // popup.add(item); item = new JMenuItem(actionScrapeSelected); popup.add(item); item = new JMenuItem(actionScrapeNewItems); popup.add(item); buttonScrape.setPopupMenu(popup); toolBar.add(buttonScrape); toolBar.add(actionEdit); JButton btnMediaInformation = new JButton(); btnMediaInformation.setAction(actionMediaInformation); toolBar.add(btnMediaInformation); // install drawing of full with tree = new ZebraJTree(treeModel) { private static final long serialVersionUID = 2422163883324014637L; @Override public void paintComponent(Graphics g) { width = this.getWidth(); super.paintComponent(g); } }; tvShowSelectionModel = new TvShowSelectionModel(tree); TreeUI ui = new TreeUI() { @Override protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) { bounds.width = width - bounds.x; super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); } }; tree.setUI(ui); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.setCellRenderer(new TvShowTreeCellRenderer()); tree.setRowHeight(0); scrollPane.setViewportView(tree); JPanel panelHeader = new JPanel() { private static final long serialVersionUID = -6914183798172482157L; @Override public void paintComponent(Graphics g) { super.paintComponent(g); JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getColHeaderColors(), 0, 0, getWidth(), getHeight()); } }; scrollPane.setColumnHeaderView(panelHeader); panelHeader.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("center:20px"), ColumnSpec.decode("center:20px"), ColumnSpec.decode("center:20px") }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, })); JLabel lblTvShowsColumn = new JLabel(BUNDLE.getString("metatag.tvshow")); //$NON-NLS-1$ lblTvShowsColumn.setHorizontalAlignment(JLabel.CENTER); panelHeader.add(lblTvShowsColumn, "2, 1"); JLabel lblNfoColumn = new JLabel(""); lblNfoColumn.setHorizontalAlignment(JLabel.CENTER); lblNfoColumn.setIcon(IconManager.INFO); lblNfoColumn.setToolTipText(BUNDLE.getString("metatag.nfo"));//$NON-NLS-1$ panelHeader.add(lblNfoColumn, "4, 1"); JLabel lblImageColumn = new JLabel(""); lblImageColumn.setHorizontalAlignment(JLabel.CENTER); lblImageColumn.setIcon(IconManager.IMAGE); lblImageColumn.setToolTipText(BUNDLE.getString("metatag.images"));//$NON-NLS-1$ panelHeader.add(lblImageColumn, "5, 1"); JLabel lblSubtitleColumn = new JLabel(""); lblSubtitleColumn.setHorizontalAlignment(JLabel.CENTER); lblSubtitleColumn.setIcon(IconManager.SUBTITLE); lblSubtitleColumn.setToolTipText(BUNDLE.getString("metatag.subtitles"));//$NON-NLS-1$ panelHeader.add(lblSubtitleColumn, "6, 1"); JPanel panel = new JPanel(); panelTvShowTree.add(panel, "2, 5, 3, 1, fill, fill"); panel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JLabel lblTvShowsT = new JLabel(BUNDLE.getString("metatag.tvshows") + ":"); //$NON-NLS-1$ panel.add(lblTvShowsT, "1, 2, fill, fill"); lblTvShows = new JLabel(""); panel.add(lblTvShows, "3, 2"); JLabel labelSlash = new JLabel("/"); panel.add(labelSlash, "5, 2"); JLabel lblEpisodesT = new JLabel(BUNDLE.getString("metatag.episodes") + ":"); //$NON-NLS-1$ panel.add(lblEpisodesT, "7, 2"); lblEpisodes = new JLabel(""); panel.add(lblEpisodes, "9, 2"); JLayeredPane layeredPaneRight = new JLayeredPane(); layeredPaneRight.setLayout( new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") }, new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") })); panelRight = new JPanel(); layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill"); layeredPaneRight.setLayer(panelRight, 0); // glass pane final TvShowExtendedSearchPanel panelExtendedSearch = new TvShowExtendedSearchPanel(treeModel, tree); panelExtendedSearch.setVisible(false); // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill"); btnFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (panelExtendedSearch.isVisible() == true) { panelExtendedSearch.setVisible(false); } else { panelExtendedSearch.setVisible(true); } } }); // add a propertychangelistener which reacts on setting a filter tree.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("filterChanged".equals(evt.getPropertyName())) { if (Boolean.TRUE.equals(evt.getNewValue())) { btnFilter.setIcon(IconManager.FILTER_ACTIVE); btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$ } else { btnFilter.setIcon(IconManager.FILTER); btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$ } } } }); layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill"); layeredPaneRight.setLayer(panelExtendedSearch, 1); splitPane.setRightComponent(layeredPaneRight); panelRight.setLayout(new CardLayout(0, 0)); JPanel panelTvShow = new TvShowInformationPanel(tvShowSelectionModel); panelRight.add(panelTvShow, "tvShow"); JPanel panelTvShowSeason = new TvShowSeasonInformationPanel(tvShowSeasonSelectionModel); panelRight.add(panelTvShowSeason, "tvShowSeason"); JPanel panelTvShowEpisode = new TvShowEpisodeInformationPanel(tvShowEpisodeSelectionModel); panelRight.add(panelTvShowEpisode, "tvShowEpisode"); tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node != null) { // click on a tv show if (node.getUserObject() instanceof TvShow) { TvShow tvShow = (TvShow) node.getUserObject(); tvShowSelectionModel.setSelectedTvShow(tvShow); CardLayout cl = (CardLayout) (panelRight.getLayout()); cl.show(panelRight, "tvShow"); } // click on a season if (node.getUserObject() instanceof TvShowSeason) { TvShowSeason tvShowSeason = (TvShowSeason) node.getUserObject(); tvShowSeasonSelectionModel.setSelectedTvShowSeason(tvShowSeason); CardLayout cl = (CardLayout) (panelRight.getLayout()); cl.show(panelRight, "tvShowSeason"); } // click on an episode if (node.getUserObject() instanceof TvShowEpisode) { TvShowEpisode tvShowEpisode = (TvShowEpisode) node.getUserObject(); tvShowEpisodeSelectionModel.setSelectedTvShowEpisode(tvShowEpisode); CardLayout cl = (CardLayout) (panelRight.getLayout()); cl.show(panelRight, "tvShowEpisode"); } } else { // check if there is at least one tv show in the model TvShowRootTreeNode root = (TvShowRootTreeNode) tree.getModel().getRoot(); if (root.getChildCount() == 0) { // sets an inital show tvShowSelectionModel.setSelectedTvShow(null); } } } }); addComponentListener(new ComponentAdapter() { @Override public void componentHidden(ComponentEvent e) { menu.setVisible(false); super.componentHidden(e); } @Override public void componentShown(ComponentEvent e) { menu.setVisible(true); super.componentHidden(e); } }); // further initializations init(); initDataBindings(); // selecting first TV show at startup if (tvShowList.getTvShows() != null && tvShowList.getTvShows().size() > 0) { DefaultMutableTreeNode firstLeaf = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) tree.getModel() .getRoot()).getFirstChild(); tree.setSelectionPath(new TreePath(((DefaultMutableTreeNode) firstLeaf.getParent()).getPath())); tree.setSelectionPath(new TreePath(firstLeaf.getPath())); } }
From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.OtherIndividualsGeneSubInspector.java
@Override protected JPanel getIndividualSummaryPanel(String dnaID) { JPanel outerPanel = new JPanel(); outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS)); //dnaIDVariantMap.get(DNAId) -- all variants within gene corresponding to individual Set<VariantRecord> variantRecords = getVariantRecords(dnaID); Map<Long, Set<VariantRecord>> positionVariantMap = new TreeMap<Long, Set<VariantRecord>>(); for (VariantRecord variantRecord : variantRecords) { //Get all variants at that overlap at that position, regardless of individual. Set<VariantRecord> variantsAtPosition = positionVariantMap.get(variantRecord.getStartPosition()); if (variantsAtPosition == null) { variantsAtPosition = new HashSet<VariantRecord>(); }//from w ww . j a v a 2 s . c om variantsAtPosition.add(variantRecord); positionVariantMap.put(variantRecord.getStartPosition(), variantsAtPosition); } for (Map.Entry<Long, Set<VariantRecord>> e : positionVariantMap.entrySet()) { Long pos = e.getKey(); Set<VariantRecord> variantsAtPosition = e.getValue(); for (final VariantRecord variantRecord : variantsAtPosition) { final JPanel rowContainer = new JPanel(); rowContainer.setLayout(new BoxLayout(rowContainer, BoxLayout.Y_AXIS)); final JPanel row = new JPanel(); row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS)); row.setBorder(new EmptyBorder(0, MIDDLE_LEVEL_INDENT, 0, 0)); final JLabel showDetailsButton = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND)); String posStr = NumberFormat.getNumberInstance().format(pos); JLabel rowTitle = new JLabel( " " + variantRecord.getZygosity().name() + " " + variantRecord.getType() + " @ " + posStr); row.add(showDetailsButton); row.add(rowTitle); row.add(Box.createHorizontalGlue()); rowContainer.add(row); outerPanel.add(rowContainer); showDetailsButton.addMouseListener(new MouseAdapter() { private boolean expanded = true; @Override public void mousePressed(MouseEvent me) { if (expanded) { showDetailsButton .setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.COLLAPSE)); int last_level_indent = MIDDLE_LEVEL_INDENT + IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND) .getIconWidth() + rowContainer.getFontMetrics(rowContainer.getFont()).charWidth(' '); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.setBorder(new EmptyBorder(0, last_level_indent, 0, 0)); JPanel textPanel = new JPanel(); textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS)); textPanel.add(new JLabel("Ref: " + variantRecord.getRef())); textPanel.add(Box.createHorizontalGlue()); p.add(textPanel); textPanel = new JPanel(); textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS)); textPanel.add(new JLabel("Alt: " + variantRecord.getAlt())); textPanel.add(Box.createHorizontalGlue()); p.add(textPanel); rowContainer.add(p); } else { showDetailsButton .setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND)); rowContainer.removeAll(); rowContainer.add(row); } rowContainer.revalidate(); rowContainer.repaint(); expanded = !expanded; } }); } } return outerPanel; }
From source file:org.xulux.swing.util.SwingUtilsTest.java
/** * Test the swing components for accepting null values in images and imageIcons. *//* ww w . ja v a 2 s . com*/ public void testSwingComponents() { System.out.println("testSwingComponents"); JLabel label = new JLabel((Icon) null); label.setIcon(null); JButton button = new JButton((Icon) null); button.setIcon(null); }
From source file:paquete.Ventana.java
private void muestraRecorridoMapa() { //Cambia los siguientes valores por las direciones de origen y destino deseadas String origen = jTextLatitud.getText() + "," + jTextLongitud.getText(); String destino = jTextDestino.getText(); //Hay que sustituir los espacios por el carcter %20 para que se // interprete bien la URL que se generar destino = destino.replaceAll(" ", "%20"); //Cambia el nombre [etiqueta] por el nombre de un objeto JLabel (etiqueta) que // has debido colocar antes en el formulario y que ser donde se muestre el mapa. // Deja la etiqueta del formulario sin ningn texto en el diseo. javax.swing.JLabel jLabelMapa = jLabelMapaRuta; //Indica aqu el tamao que desees para el mapa int tamHorizontal = 200; int tamVertical = 200; //Puedes encontrar ms informacin sobre el uso de mapas estticos de Google Maps aqu: // http://code.google.com/intl/es-ES/apis/maps/documentation/staticmaps/ //A partir de aqu no hace falta cambiar nada try {/*from www .j ava 2s .c om*/ String txtDireccionImagenMapa = "http://maps.google.com/maps/api/staticmap?path=" + origen + "|" + destino + "&size=" + tamHorizontal + "x" + tamVertical + "&language=ES&sensor=false"; System.out.println(txtDireccionImagenMapa); java.awt.Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit(); java.awt.Image imagenMapa = toolkit.getImage(new java.net.URL(txtDireccionImagenMapa)); jLabelMapa.setIcon(new javax.swing.ImageIcon(imagenMapa)); } catch (java.net.MalformedURLException e) { javax.swing.JOptionPane.showMessageDialog(this, "La direccin de imagen indicada no es correcta"); } }
From source file:picocash.renderer.list.NameAndIconListRenderer.java
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof NameAndIconable) { NameAndIconable nameAndIconable = (NameAndIconable) value; label.setText(nameAndIconable.getName()); label.setIcon(PicocashIcons.getIcon(nameAndIconable.getIcon())); } else {//from w w w . j a va2s . c o m label.setIcon(PicocashIcons.getIcon(value + "")); } return label; }
From source file:pl.otros.logview.gui.LogViewPanel.java
private void addFiltersGUIsToPanel(JPanel filtersPanel) { filtersPanel.setLayout(new MigLayout("", "[grow]", "")); Collection<LogFilter> loadedFilters = logFiltersContainer.getElements(); // Reload filters, every instance of filter is connected to listeners, data table etc. filtersList = new ArrayList<LogFilter>(); for (LogFilter logFilter : loadedFilters) { try {/*w w w . j a va 2 s .c o m*/ LogFilter filter = logFilter.getClass().newInstance(); filtersList.add(filter); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Can't initialize filter: " + logFilter.getClass(), e); } } JLabel filtersLabel = new JLabel("Filters:"); filtersLabel.setMinimumSize(new Dimension(200, 16)); filtersLabel.setPreferredSize(new Dimension(200, 16)); filtersLabel.setIcon(Icons.FILTER); Font f = filtersLabel.getFont().deriveFont(Font.BOLD); filtersLabel.setFont(f); filtersPanel.add(filtersLabel, "wrap, growx, span"); LogFilterValueChangeListener listener = new LogFilterValueChangeListener(table, sorter, filtersList, statusObserver); for (LogFilter filter : filtersList) { filter.init(new Properties(), dataTableModel); FilterPanel filterPanel = new FilterPanel(filter, listener); filtersPanel.add(filterPanel, "wrap, growx"); if (filter instanceof ThreadFilter) { ThreadFilter threadFilter = (ThreadFilter) filter; focusOnThisThreadAction = new FocusOnThisThreadAction(threadFilter, filterPanel.getEnableCheckBox(), otrosApplication); } else if (filter instanceof TimeFilter) { focusOnEventsAfter = new FocusOnEventsAfter((TimeFilter) filter, filterPanel.getEnableCheckBox(), otrosApplication); focusOnEventsBefore = new FocusOnEventsBefore((TimeFilter) filter, filterPanel.getEnableCheckBox(), otrosApplication); } else if (filter instanceof ClassFilter) { focusOnSelectedClassesAction = new FocusOnSelectedClassesAction((ClassFilter) filter, filterPanel.getEnableCheckBox(), otrosApplication); ignoreSelectedEventsClasses = new IgnoreSelectedEventsClasses((ClassFilter) filter, filterPanel.getEnableCheckBox(), otrosApplication); } else if (filter instanceof LoggerNameFilter) { focusOnSelectedLoggerNameAction = new FocusOnSelectedLoggerNameAction((LoggerNameFilter) filter, filterPanel.getEnableCheckBox(), otrosApplication); } else if (filter instanceof CallHierarchyLogFilter) { showCallHierarchyAction = new ShowCallHierarchyAction((CallHierarchyLogFilter) filter, filterPanel.getEnableCheckBox(), otrosApplication); } else if (filter instanceof PropertyFilter) { propertyFilter = (PropertyFilter) filter; propertyFilterPanel = filterPanel; } } filtersLabel.add(logsMarkersPanel, "span, grow"); }
From source file:pl.otros.vfs.browser.table.FileNameWithTypeTableCellRenderer.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);// w ww. j a v a 2 s . c om FileNameWithType fileNameWithType = (FileNameWithType) value; FileName fileName = fileNameWithType.getFileName(); label.setText(fileName.getBaseName()); label.setToolTipText(fileName.getFriendlyURI()); FileType fileType = fileNameWithType.getFileType(); Icon icon = null; Icons icons = Icons.getInstance(); if (fileNameWithType.getFileName().getBaseName().equals(ParentFileObject.PARENT_NAME)) { icon = icons.getArrowTurn90(); } else if (FileType.FOLDER.equals(fileType)) { icon = icons.getFolderOpen(); } else if (VFSUtils.isArchive(fileName)) { if ("jar".equalsIgnoreCase(fileName.getExtension())) { icon = icons.getJarIcon(); } else { icon = icons.getFolderZipper(); } } else if (FileType.FILE.equals(fileType)) { icon = icons.getFile(); } else if (FileType.IMAGINARY.equals(fileType)) { icon = icons.getShortCut(); } label.setIcon(icon); return label; }
From source file:rita.ui.component.DialogSelectEnemies.java
/** * Initialize the contents of the frame. * /*from w w w . ja va2 s . c om*/ * @throws NoEnemiesException */ private void initialize() throws NoEnemiesException { this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.getContentPane().setLayout(new BorderLayout(6, 6)); this.setTitle(Language.get("selectEnemies")); randomMode = new JCheckBox(Language.get("robotsBattleMode.random")); randomMode.setSelected(true); randomMode.addActionListener(new SelectUnselectPositionAction()); icon = new ImageIcon(DialogSelectEnemies.class.getResource("/images/icons/target.jpg")); JPanel panelRobots = new JPanel(); panelRobots.setBorder(new EmptyBorder(0, 12, 12, 0)); panelRobots.setLayout(new BorderLayout(0, 0)); JPanel panelSelectAllNone = new JPanel(); panelSelectAllNone.setBorder(new EmptyBorder(0, 12, 0, 12)); panelRobots.add(panelSelectAllNone, BorderLayout.EAST); this.getContentPane().add(panelRobots, BorderLayout.CENTER); GridBagLayout gbl_panelSelectAllNone = new GridBagLayout(); gbl_panelSelectAllNone.columnWidths = new int[] { 0, 0 }; gbl_panelSelectAllNone.rowHeights = new int[] { 0, 0, 8 }; gbl_panelSelectAllNone.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; gbl_panelSelectAllNone.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; panelSelectAllNone.setLayout(gbl_panelSelectAllNone); JButton btnSelectAll = new JButton(Language.get("selectAllEnemies")); GridBagConstraints gbc_btnSelectAll = new GridBagConstraints(); gbc_btnSelectAll.fill = GridBagConstraints.HORIZONTAL; gbc_btnSelectAll.insets = new Insets(0, 0, 5, 0); gbc_btnSelectAll.gridx = 0; gbc_btnSelectAll.gridy = 0; panelSelectAllNone.add(btnSelectAll, gbc_btnSelectAll); JButton btnSelectNone = new JButton(Language.get("selectNoEnemies")); GridBagConstraints gbc_btnSelectNone = new GridBagConstraints(); gbc_btnSelectNone.fill = GridBagConstraints.HORIZONTAL; gbc_btnSelectNone.gridx = 0; gbc_btnSelectNone.gridy = 1; panelSelectAllNone.add(btnSelectNone, gbc_btnSelectNone); /* * btnInitialPositionsConfig = new * JButton(Language.get("selectRobotsInitialPositions")); * GridBagConstraints gbc_btnInitialPositionsConfig = new * GridBagConstraints(); gbc_btnSelectNone.fill = * GridBagConstraints.HORIZONTAL; gbc_btnSelectNone.gridx = 0; * gbc_btnSelectNone.gridy = 1; * panelSelectAllNone.add(btnInitialPositionsConfig, * gbc_btnInitialPositionsConfig); * btnInitialPositionsConfig.addActionListener(new ActionListener() { * public void actionPerformed(ActionEvent evt) { * selectRobotsInitialPositions(); } }); */ JLabel label = new JLabel(String.format(Language.get("youtRobotAgainst"), HelperEditor.currentRobotName)); label.setBorder(new EmptyBorder(12, 12, 0, 12)); label.setIcon(new ImageIcon(DialogSelectEnemies.class.getResource("/images/icons/compite2.png"))); label.setVerticalAlignment(SwingConstants.TOP); label.setFont(label.getFont().deriveFont(Font.BOLD, 14)); panelSelectRobots = new JPanel(); panelSelectRobots.setLayout(new GridLayout(0, 2)); panelSelectRobots.setAutoscrolls(true); panelRobots.add(label, BorderLayout.NORTH); panelRobots.add(panelSelectRobots, BorderLayout.CENTER); // posicion de mi robot JPanel panelSetMyRobotPosition = new JPanel(); // panelRobots.add(panelSetMyRobotPosition, BorderLayout.PAGE_END); panelSetMyRobotPosition.setLayout(new FlowLayout()); JLabel ownPosition = new JLabel(Language.get("myRobotPosition") + " " + HelperEditor.currentRobotName); ownPosition.setFont(new Font("sansserif", Font.BOLD, 12)); panelSetMyRobotPosition.add(ownPosition); // Posicion de mi robot buttonPos = new JButton(icon); buttonPos.addActionListener(new PosicionRobotAction(HelperEditor.currentRobotName)); // el nombre aqui es solo a // modo informativo buttonPos.setPreferredSize(new Dimension(30, 30)); panelSetMyRobotPosition.add(buttonPos); positionComponents.add(buttonPos); // Matas JPanel panelSelectRoundsNumber = new JPanel(); // panelRobots.add(panelSelectRoundsNumber, BorderLayout.SOUTH); panelSelectRoundsNumber.setLayout(new FlowLayout()); panelSelectRoundsNumber.add(new JLabel(Language.get("selectRoundsNumber"))); // this.roundsNumberTextField = new JTextField( // Integer.toString(Batalla.NUMBER_OF_ROUNDS), 5); this.roundsNumberSpinner = new JSpinner(new SpinnerNumberModel(Batalla.NUMBER_OF_ROUNDS, Batalla.MIN_NUMBER_OF_ROUNDS, Batalla.MAX_NUMBER_OF_ROUNDS, 1)); panelSelectRoundsNumber.add(this.roundsNumberSpinner); JPanel panelSouth = new JPanel(); panelSouth.setLayout(new GridLayout(4, 1)); panelSouth.add(panelSetMyRobotPosition); //this.getContentPane().add(randomMode, BorderLayout.SOUTH); panelSouth.add(randomMode); panelSouth.add(new JSeparator()); panelSouth.add(panelSelectRoundsNumber); panelRobots.add(panelSouth, BorderLayout.SOUTH); JPanel panelOkCancel = new JPanel(); this.getContentPane().add(panelOkCancel, BorderLayout.SOUTH); panelOkCancel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 12)); btnOK = new JButton(Language.get("selectStartBattle")); btnOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { startBattle(panelSelectRobots); } }); // comienza deshabilitado hasta que se seleccione 1 enemigo // btnOK.setEnabled(false); panelOkCancel.add(btnOK); JButton btnCancel = new JButton(Language.get("cancel")); btnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { closeDialog(); } }); panelOkCancel.add(btnCancel); btnSelectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { selectChecks(panelSelectRobots, true); // btnOK.setEnabled(true); } }); btnSelectNone.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { selectChecks(panelSelectRobots, false); // btnOK.setEnabled(false); } }); // TODO Agregar funcionalidad de elegir las posiciones iniciales de los // robots. // TODO Averiguar como pasar las posiciones para que se elijan de manera // random, probar (0,0,0) try { robotNameClicked = new RobotNameClickedEvent(btnOK); addRobotsToPanel(panelSelectRobots); this.setResizable(false); this.pack(); PositionCalc.centerDialog(this); enablePositionOptions(false); this.setVisible(true); } catch (FileNotFoundException e) { throw new NoEnemiesException(e.getMessage()); } }
From source file:se.llbit.chunky.renderer.ui.RenderControls.java
private JPanel buildCameraPane() { JLabel projectionModeLbl = new JLabel("Projection"); fov.update();//from www .ja v a2 s.c o m dof = new DoFAdjuster(renderMan); dof.update(); subjectDistance.update(); JLabel presetLbl = new JLabel("Preset:"); CameraPreset[] presets = { CameraPreset.NONE, CameraPreset.ISO_WEST_NORTH, CameraPreset.ISO_NORTH_EAST, CameraPreset.ISO_EAST_SOUTH, CameraPreset.ISO_SOUTH_WEST, CameraPreset.SKYBOX_RIGHT, CameraPreset.SKYBOX_LEFT, CameraPreset.SKYBOX_UP, CameraPreset.SKYBOX_DOWN, CameraPreset.SKYBOX_FRONT, CameraPreset.SKYBOX_BACK, }; cameraPreset.setModel(new DefaultComboBoxModel(presets)); cameraPreset.setMaximumRowCount(presets.length); final int presetHeight = cameraPreset.getPreferredSize().height; final int presetWidth = cameraPreset.getPreferredSize().width; cameraPreset.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); label.setPreferredSize(new Dimension(presetWidth, presetHeight)); CameraPreset preset = (CameraPreset) value; label.setIcon(preset.getIcon()); return label; } }); cameraPreset.addActionListener(cameraPresetListener); JLabel customPresetLbl = new JLabel("Custom preset:"); customPreset.setEditable(true); updateCustomPresets(); JButton savePreset = new JButton("save"); savePreset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String name = ""; int selected = customPreset.getSelectedIndex(); if (selected == -1) { // select name name = (String) customPreset.getEditor().getItem(); name = (name == null) ? "" : name.trim(); if (name.isEmpty()) { // auto-assign name int nextIndex = customPreset.getItemCount() + 1; outer: while (true) { name = "custom-" + (nextIndex++); for (int i = 0; i < customPreset.getItemCount(); ++i) { String item = (String) customPreset.getItemAt(i); if (name.equals(item)) { continue outer; } } break; } } else { for (int i = 0; i < customPreset.getItemCount(); ++i) { String item = (String) customPreset.getItemAt(i); if (name.equals(item)) { selected = i; break; } } } if (selected == -1) { // add new preset selected = customPreset.getItemCount(); customPreset.addItem(name); } customPreset.setSelectedIndex(selected); } else { name = (String) customPreset.getSelectedItem(); } renderMan.scene().saveCameraPreset(name); } }); JButton loadPreset = new JButton("load"); loadPreset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String name = ""; int selected = customPreset.getSelectedIndex(); if (selected == -1) { // select name name = (String) customPreset.getEditor().getItem(); name = (name == null) ? "" : name.trim(); } else { name = ((String) customPreset.getSelectedItem()).trim(); } if (!name.isEmpty()) { renderMan.scene().loadCameraPreset(name); } } }); JButton deletePreset = new JButton("delete"); deletePreset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String name = ""; int selected = customPreset.getSelectedIndex(); if (selected == -1) { // select name name = (String) customPreset.getEditor().getItem(); name = (name == null) ? "" : name.trim(); } else { name = ((String) customPreset.getSelectedItem()).trim(); } if (!name.isEmpty()) { renderMan.scene().deleteCameraPreset(name); if (selected != -1) { customPreset.removeItemAt(selected); } else { for (int i = 0; i < customPreset.getItemCount(); ++i) { if (name.equals(customPreset.getItemAt(i))) { customPreset.removeItemAt(i); break; } } } } } }); ProjectionMode[] projectionModes = ProjectionMode.values(); projectionMode.setModel(new DefaultComboBoxModel(projectionModes)); projectionMode.addActionListener(projectionModeListener); updateProjectionMode(); JButton autoFocusBtn = new JButton("Autofocus"); autoFocusBtn.setToolTipText("Focuses on the object right in the center, under the crosshairs"); autoFocusBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renderMan.scene().autoFocus(); dof.update(); subjectDistance.update(); } }); JButton cameraToPlayerBtn = new JButton("Camera to player"); cameraToPlayerBtn.setToolTipText("Move camera to player position"); cameraToPlayerBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renderMan.scene().moveCameraToPlayer(); } }); JLabel posLbl = new JLabel("Position:"); cameraX.setColumns(10); cameraX.setHorizontalAlignment(JTextField.RIGHT); cameraX.addActionListener(cameraPositionListener); cameraY.setColumns(10); cameraY.setHorizontalAlignment(JTextField.RIGHT); cameraY.addActionListener(cameraPositionListener); cameraZ.setColumns(10); cameraZ.setHorizontalAlignment(JTextField.RIGHT); cameraZ.addActionListener(cameraPositionListener); updateCameraPosition(); JLabel dirLbl = new JLabel("Direction:"); cameraYaw.setColumns(10); cameraYaw.setHorizontalAlignment(JTextField.RIGHT); cameraYaw.addActionListener(cameraDirectionListener); cameraPitch.setColumns(10); cameraPitch.setHorizontalAlignment(JTextField.RIGHT); cameraPitch.addActionListener(cameraDirectionListener); cameraRoll.setColumns(10); cameraRoll.setHorizontalAlignment(JTextField.RIGHT); cameraRoll.addActionListener(cameraDirectionListener); updateCameraDirection(); JButton centerCameraBtn = new JButton("Center camera"); centerCameraBtn.setToolTipText("Center camera above loaded chunks"); centerCameraBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { renderMan.scene().moveCameraToCenter(); } }); JSeparator sep1 = new JSeparator(); JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setHorizontalGroup( layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup().addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup().addComponent(posLbl).addComponent(dirLbl)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup() .addComponent(cameraX, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(cameraYaw, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup() .addComponent(cameraY, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(cameraPitch, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup() .addComponent(cameraZ, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(cameraRoll, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup().addComponent(presetLbl) .addPreferredGap(ComponentPlacement.RELATED).addComponent(cameraPreset)) .addGroup(layout.createSequentialGroup().addComponent(customPresetLbl) .addPreferredGap(ComponentPlacement.RELATED).addComponent(customPreset) .addPreferredGap(ComponentPlacement.RELATED).addComponent(savePreset) .addPreferredGap(ComponentPlacement.RELATED).addComponent(loadPreset) .addPreferredGap(ComponentPlacement.RELATED).addComponent(deletePreset)) .addGroup(layout.createSequentialGroup().addComponent(cameraToPlayerBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(centerCameraBtn)) .addComponent(sep1) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup().addComponent(projectionModeLbl) .addComponent(fov.getLabel()).addComponent(dof.getLabel()) .addComponent(subjectDistance.getLabel())) .addGroup(layout.createParallelGroup().addComponent(projectionMode) .addComponent(fov.getSlider()).addComponent(dof.getSlider()) .addComponent(subjectDistance.getSlider())) .addGroup(layout.createParallelGroup().addComponent(fov.getField()) .addComponent(dof.getField()) .addComponent(subjectDistance.getField()))) .addComponent(autoFocusBtn)) .addContainerGap()); layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout .createParallelGroup(Alignment.BASELINE).addComponent(presetLbl).addComponent(cameraPreset)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(customPresetLbl) .addComponent(customPreset).addComponent(savePreset).addComponent(loadPreset) .addComponent(deletePreset)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(posLbl).addComponent(cameraX) .addComponent(cameraY).addComponent(cameraZ)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(dirLbl) .addComponent(cameraYaw).addComponent(cameraPitch).addComponent(cameraRoll)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup( layout.createParallelGroup().addComponent(cameraToPlayerBtn).addComponent(centerCameraBtn)) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent( sep1, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(projectionModeLbl) .addComponent(projectionMode)) .addPreferredGap(ComponentPlacement.RELATED).addGroup(fov.verticalGroup(layout)) .addGroup(dof.verticalGroup(layout)).addGroup(subjectDistance.verticalGroup(layout)) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(autoFocusBtn).addContainerGap()); return panel; }