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.martin.ftp.model.TCRSearch.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel lbl = new JLabel(); ImageIcon icon;//from www . j a va 2 s . c o m FTPFile file = files.get(row).getFile(); if (column == 0) { if (file.isDirectory()) icon = new ImageIcon(getClass().getResource("/org/martin/ftp/resources/folder.png")); else icon = new ImageIcon(getClass().getResource("/org/martin/ftp/resources/file.png")); lbl.setIcon(icon); lbl.setText(file.getName()); } else lbl.setText(value.toString()); Color bg = lbl.getBackground(); if (isSelected) lbl.setBackground(Color.CYAN); else lbl.setBackground(bg); lbl.setOpaque(true); return lbl; }
From source file:org.n52.ifgicopter.spf.gui.SPFMainFrame.java
/** * helper method. creates tab labels with icons on the left side. *///from ww w . j a v a2 s . c o m private void addTab(Component tab, String title, Icon icon) { this.pane.add(tab); // Create bespoke component for rendering the tab. JLabel lbl = new JLabel(title); lbl.setIcon(icon); // Add some spacing between text and icon, and position text to the RHS. lbl.setIconTextGap(2); lbl.setHorizontalTextPosition(SwingConstants.RIGHT); this.pane.setTabComponentAt(this.pane.getTabCount() - 1, lbl); }
From source file:org.ngrinder.recorder.ui.AboutDialog.java
private JLabel getIcon() { JLabel icon = new JLabel(); icon.setIcon(ResourceUtil.getIcon("recorder32x32.png")); icon.setAlignmentX(CENTER_ALIGNMENT); return icon;/*from ww w . jav a2 s . c om*/ }
From source file:org.nuclos.client.dbtransfer.DBTransferImport.java
private boolean setupPreviewPanel(List<PreviewPart> previewParts) { boolean blnTransferWithWarnings = false; jpnPreviewHeader.removeAll();/*w ww .j a v a2 s . com*/ jpnPreviewFooter.removeAll(); // setup parameter scroll pane jpnPreviewContent.removeAll(); double[] rowContraints = new double[previewParts.size()]; for (int i = 0; i < previewParts.size(); i++) rowContraints[i] = TableLayout.PREFERRED; final int iWidthBeginnigSpace = 3; final int iWidthSeparator = 6; final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); JLabel lbPreviewHeaderEntity = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.11", "Entit\u00e4t")); JLabel lbPreviewHeaderTable = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.12", "Tabellenname")); JLabel lbPreviewHeaderRecords = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.4", "Datens\u00e4tze")); lbPreviewHeaderRecords.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.5", "Anzahl der betroffenen Datens\u00e4tze")); utils.initJPanel(jpnPreviewContent, new double[] { iWidthBeginnigSpace, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED }, rowContraints); int iWidthEntityLabelSize = 0; int iWidthTableLabelSize = 0; int iWidthRecordsLabelSize = 0; int iCountNew = 0; int iCountDeleted = 0; int iCountChanged = 0; int iRow = 0; for (final PreviewPart pp : previewParts) { String tooltip = ""; JLabel lbEntity = new JLabel(pp.getEntity()); JLabel lbTable = new JLabel(pp.getTable()); JLabel lbRecords = new JLabel(String.valueOf(pp.getDataRecords())); lbRecords.setHorizontalAlignment(SwingConstants.RIGHT); if (lbEntity.getPreferredSize().width < lbPreviewHeaderEntity.getPreferredSize().width) lbEntity.setPreferredSize(lbPreviewHeaderEntity.getPreferredSize()); if (lbTable.getPreferredSize().width < lbPreviewHeaderTable.getPreferredSize().width) lbTable.setPreferredSize(lbPreviewHeaderTable.getPreferredSize()); if (lbRecords.getPreferredSize().width < lbPreviewHeaderRecords.getPreferredSize().width) lbRecords.setPreferredSize(lbPreviewHeaderRecords.getPreferredSize()); iWidthEntityLabelSize = iWidthEntityLabelSize < lbEntity.getPreferredSize().width ? lbEntity.getPreferredSize().width : iWidthEntityLabelSize; iWidthTableLabelSize = iWidthTableLabelSize < lbTable.getPreferredSize().width ? lbTable.getPreferredSize().width : iWidthTableLabelSize; iWidthRecordsLabelSize = iWidthRecordsLabelSize < lbRecords.getPreferredSize().width ? lbRecords.getPreferredSize().width : iWidthRecordsLabelSize; Icon icoStatement = null; switch (pp.getType()) { case PreviewPart.NEW: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.6", "Entit\u00e4t wird hinzugef\u00fcgt"); icoStatement = ParameterEditor.COMPARE_ICON_NEW; iCountNew++; break; case PreviewPart.CHANGE: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.7", "Entit\u00e4t wird ge\u00e4ndert"); icoStatement = ParameterEditor.COMPARE_ICON_VALUE_CHANGED; iCountChanged++; break; case PreviewPart.DELETE: tooltip = localeDelegate.getMessage("dbtransfer.import.step1.8", "Entit\u00e4t wird gel\u00f6scht"); icoStatement = ParameterEditor.COMPARE_ICON_DELETED; iCountDeleted++; break; } JLabel lbIcon = new JLabel(icoStatement); JLabel lbStatemnts = new JLabel("<html><u>" + localeDelegate.getMessage("dbtransfer.import.step1.9", "Script anzeigen") + "...</u></html>"); lbStatemnts.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lbStatemnts.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseClicked(MouseEvent e) { String statements = ""; for (String statement : pp.getStatements()) { statements = statements + statement + ";\n\n"; } JTextArea txtArea = new JTextArea(statements); txtArea.setEditable(false); txtArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JScrollPane scroll = new JScrollPane(txtArea); scroll.getVerticalScrollBar().setUnitIncrement(20); scroll.setPreferredSize(new Dimension(600, 300)); scroll.setBorder(BorderFactory.createEmptyBorder()); MainFrameTab overlayFrame = new MainFrameTab( localeDelegate.getMessage("dbtransfer.import.step1.10", "Script f\u00fcr") + " " + pp.getEntity() + " (" + pp.getTable() + ")"); overlayFrame.setLayeredComponent(scroll); ifrm.add(overlayFrame); } }); lbIcon.setToolTipText(tooltip); lbStatemnts.setToolTipText(tooltip); lbEntity.setToolTipText(tooltip); lbTable.setToolTipText(tooltip); jpnPreviewContent.add(lbEntity, "1," + iRow + ",l,c"); jpnPreviewContent.add(lbTable, "3," + iRow + ",l,c"); jpnPreviewContent.add(lbRecords, "5," + iRow + ",r,c"); jpnPreviewContent.add(lbIcon, "7," + iRow + ",l,c"); jpnPreviewContent.add(lbStatemnts, "8," + iRow + ",l,c"); if (pp.getWarning() > 0) { lbIcon.setIcon(Icons.getInstance().getIconPriorityCancel16()); blnTransferWithWarnings = true; } iRow++; } jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "2,0,2," + (iRow - 1)); jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "4,0,4," + (iRow - 1)); jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "6,0,6," + (iRow - 1)); // setup preview header utils.initJPanel(jpnPreviewHeader, new double[] { iWidthBeginnigSpace, iWidthEntityLabelSize, iWidthSeparator, iWidthTableLabelSize, iWidthSeparator, iWidthRecordsLabelSize, iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED, TableLayout.PREFERRED }, new double[] { TableLayout.PREFERRED }); if (previewParts.isEmpty()) { jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.18", "Keine Struktur\u00e4nderungen am Datenbankschema.")), "0,0,8,0"); return blnTransferWithWarnings; } jpnPreviewHeader.add(lbPreviewHeaderEntity, "1,0"); jpnPreviewHeader.add(lbPreviewHeaderTable, "3,0"); jpnPreviewHeader.add(lbPreviewHeaderRecords, "5,0"); jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.13", "\u00c4nderung")), "7,0"); // setup preview footer utils.initJPanel(jpnPreviewFooter, new double[] { TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED }, new double[] { TableLayout.PREFERRED }); final JLabel lbCompare = new JLabel( localeDelegate.getMessage("dbtransfer.import.step1.14", "\u00c4nderungen") + ":"); final JLabel lbCompareNew = new JLabel(iCountNew + ""); final JLabel lbCompareDeleted = new JLabel(iCountDeleted + ""); final JLabel lbCompareValueChanged = new JLabel(iCountChanged + ""); lbCompareNew.setIcon(ParameterEditor.COMPARE_ICON_NEW); lbCompareDeleted.setIcon(ParameterEditor.COMPARE_ICON_DELETED); lbCompareValueChanged.setIcon(ParameterEditor.COMPARE_ICON_VALUE_CHANGED); lbCompareNew.setToolTipText(localeDelegate.getMessage("dbtransfer.import.step1.15", "Neue Entit\u00e4ten")); lbCompareDeleted.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.17", "Gel\u00f6schte Entit\u00e4ten")); lbCompareValueChanged.setToolTipText( localeDelegate.getMessage("dbtransfer.import.step1.16", "Ge\u00e4nderte Entit\u00e4ten")); jpnPreviewFooter.add(lbCompare, "1,0,r,c"); jpnPreviewFooter.add(lbCompareNew, "2,0,r,c"); jpnPreviewFooter.add(lbCompareValueChanged, "3,0,r,c"); jpnPreviewFooter.add(lbCompareDeleted, "4,0,r,c"); return blnTransferWithWarnings; }
From source file:org.nuclos.client.dbtransfer.DBTransferImport.java
private void setupParameterPanel(Collection<EntityObjectVO> incomingParameterVOs) { final String entity = NuclosEntity.PARAMETER.getEntityName(); List<EntityObjectVO> currentParameterVOs = new ArrayList<EntityObjectVO>( CollectionUtils.transform(MasterDataDelegate.getInstance().getMasterData(entity), DalSupportForMD.getTransformerToEntityObjectVO(entity))); int iCountNew = 0; int iCountDeleted = 0; int iCountValueChanged = 0; final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); // find new parameter and existing List<ParameterComparison> allParameter = new ArrayList<ParameterComparison>(); for (EntityObjectVO incomingParameterVO : incomingParameterVOs) { boolean blnParamFound = false; String sCurrentValue = null; for (EntityObjectVO currentParameterVO : currentParameterVOs) { if ((incomingParameterVO.getField("name", String.class)) .equals(currentParameterVO.getField("name", String.class))) { blnParamFound = true;/*from www.ja va 2 s . c o m*/ sCurrentValue = currentParameterVO.getField("value", String.class); break; } } if (!blnParamFound) { allParameter.add(new ParameterComparison(incomingParameterVO, true, false, null)); iCountNew++; } else { ParameterComparison parameter = new ParameterComparison(incomingParameterVO, false, false, sCurrentValue); allParameter.add(parameter); if (parameter.isValueChanged()) iCountValueChanged++; } } // find deleted parameter for (EntityObjectVO currentParameterVO : currentParameterVOs) { boolean blnParamFound = false; for (EntityObjectVO incomingParamVO : incomingParameterVOs) { if ((incomingParamVO.getField("name", String.class)) .equals(currentParameterVO.getField("name", String.class))) { blnParamFound = true; break; } } if (!blnParamFound) { allParameter.add(new ParameterComparison(currentParameterVO, false, true, currentParameterVO.getField("value", String.class))); iCountDeleted++; } } // sort parameter VOs List<ParameterComparison> allParameterSorted = new ArrayList<ParameterComparison>(allParameter); Collections.sort(allParameterSorted, new Comparator<ParameterComparison>() { @Override public int compare(ParameterComparison o1, ParameterComparison o2) { return StringUtils.emptyIfNull(o1.getField("name", String.class)) .compareTo(StringUtils.emptyIfNull(o2.getField("name", String.class))); } }); jpnParameterHeader.removeAll(); jpnParameterFooter.removeAll(); // setup parameter scroll pane jpnParameter.removeAll(); double[] rowContraints = new double[allParameterSorted.size()]; for (int i = 0; i < allParameterSorted.size(); i++) rowContraints[i] = TableLayout.PREFERRED; final int iWidthBeginnigSpace = 3; final int iWidthSeparator = 6; final int iWidthRadioButton = 20; utils.initJPanel(jpnParameter, new double[] { iWidthBeginnigSpace, TableLayout.PREFERRED, iWidthSeparator, iWidthRadioButton, iWidthRadioButton, iWidthRadioButton, TableLayout.FILL }, rowContraints); int iWidthLabelSize = 0; int iRow = 0; lstParameterEditors.clear(); for (ParameterComparison parameter : allParameterSorted) { final ParameterEditor pe = new ParameterEditor(parameter); // init last state if (setSelectedCurrentParameter.contains(pe.getName())) pe.setCurrentValue(); if (setSelectedIncomingParameter.contains(pe.getName())) pe.setIncomingValue(); if (mapSelectedOtherParameter.containsKey(pe.getName())) pe.setOtherValue(mapSelectedOtherParameter.get(pe.getName())); // add change listener to update the radio buttons in footer pe.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateParameterAllSelection(); } }); pe.addToStepContent(jpnParameter, iRow); lstParameterEditors.add(pe); if (pe.getLabelPrefferedSize().width > iWidthLabelSize) iWidthLabelSize = pe.getLabelPrefferedSize().width; iRow++; } updateParameterAllSelection(); jpnParameter.add(new JSeparator(JSeparator.VERTICAL), "2,0,2," + (iRow - 1)); // setup parameter header utils.initJPanel(jpnParameterHeader, new double[] { iWidthBeginnigSpace, iWidthLabelSize + iWidthSeparator + (iWidthRadioButton / 2) + utils.TABLE_LAYOUT_H_GAP + 1/*Border*/, iWidthRadioButton, iWidthRadioButton, TableLayout.FILL }, new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, 4 }); if (allParameterSorted.isEmpty()) { jpnParameterHeader.add(new JLabel( localeDelegate.getMessage("dbtransfer.import.parameterpanel.18", "Keine Parameter vorhanden.")), "1,2,4,2"); return; } jpnParameterHeader.add( new JLabel(localeDelegate.getMessage("dbtransfer.import.parameterpanel.1", "Parameter")), "1,2"); jpnParameterHeader.add(new JLabel( localeDelegate.getMessage("dbtransfer.import.parameterpanel.2", "aktuellen Zustand beibehalten")), "2,0,4,0"); jpnParameterHeader.add(new JSeparator(JSeparator.VERTICAL), "2,1,2,3"); jpnParameterHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.parameterpanel.3", "importierten Zustand \u00fcbernehmen")), "3,1,4,1"); jpnParameterHeader.add(new JSeparator(JSeparator.VERTICAL), "3,2,3,3"); jpnParameterHeader.add( new JLabel(localeDelegate.getMessage("dbtransfer.import.parameterpanel.4", "anderen Wert setzen")), "4,2"); jpnParameterHeader.add(new JSeparator(JSeparator.VERTICAL), "4,3"); // setup parameter footer utils.initJPanel(jpnParameterFooter, new double[] { iWidthBeginnigSpace, iWidthLabelSize + iWidthSeparator + utils.TABLE_LAYOUT_H_GAP + 1/*Border*/, iWidthRadioButton, iWidthRadioButton, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED }, new double[] { TableLayout.PREFERRED }); final JLabel lbCompare = new JLabel( localeDelegate.getMessage("dbtransfer.import.parameterpanel.5", "\u00c4nderungen") + ":"); final JLabel lbCompareNew = new JLabel(iCountNew + ""); final JLabel lbCompareDeleted = new JLabel(iCountDeleted + ""); final JLabel lbCompareValueChanged = new JLabel(iCountValueChanged + ""); lbCompareNew.setIcon(ParameterEditor.COMPARE_ICON_NEW); lbCompareDeleted.setIcon(ParameterEditor.COMPARE_ICON_DELETED); lbCompareValueChanged.setIcon(ParameterEditor.COMPARE_ICON_VALUE_CHANGED); lbCompare.setToolTipText(localeDelegate.getMessage("dbtransfer.import.parameterpanel.6", "Vergleich von Aktueller- und Importkonfiguration")); lbCompareNew.setToolTipText(ParameterEditor.COMPARE_DESCRIPTION_NEW); lbCompareDeleted.setToolTipText(ParameterEditor.COMPARE_DESCRIPTION_DELETED); lbCompareValueChanged.setToolTipText(ParameterEditor.COMPARE_DESCRIPTION_VALUE_CHANGED); jpnParameterFooter.add(new JLabel( localeDelegate.getMessage("dbtransfer.import.parameterpanel.7", "auf alle Parameter anwenden")), "1,0,r,c"); jpnParameterFooter.add(rbCurrentAll, "2,0,l,c"); jpnParameterFooter.add(rbIncomingAll, "3,0,l,c"); jpnParameterFooter.add(lbCompare, "4,0,r,c"); jpnParameterFooter.add(lbCompareNew, "5,0,r,c"); jpnParameterFooter.add(lbCompareValueChanged, "6,0,r,c"); jpnParameterFooter.add(lbCompareDeleted, "7,0,r,c"); }
From source file:org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement.java
public SQLComponent createComponent() { return new BaseSQLComponent(this) { private Icon iconWarning = ImageIconWarning.getInstance(); public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); Set<Class<? extends SQLElement>> s = map.keySet(); final ArrayList<Class<? extends SQLElement>> list = new ArrayList<Class<? extends SQLElement>>(s); Collections.sort(list, new Comparator<Class<? extends SQLElement>>() { public int compare(Class<? extends SQLElement> o1, Class<? extends SQLElement> o2) { return o1.getSimpleName().toString().compareTo(o2.getSimpleName().toString()); };/*from w ww . j a va 2 s.com*/ }); List<String> added = new ArrayList<String>(); for (Class<? extends SQLElement> class1 : list) { String prefix = map.get(class1); if (!added.contains(prefix)) { c.gridy++; c.gridx = 0; c.weightx = 0; added.add(prefix); SQLElement elt = Configuration.getInstance().getDirectory().getElement(class1); if (elt == null) { throw new IllegalArgumentException("Element null for class " + class1); } // Avoir JLabel labelAvoirFormat = new JLabel( StringUtils.firstUp(elt.getPluralName()) + " " + getLabelFor(prefix + FORMAT), SwingConstants.RIGHT); this.add(labelAvoirFormat, c); c.gridx++; c.weightx = 1; final JTextField fieldFormat = new JTextField(); this.add(fieldFormat, c); final JLabel labelAvoirStart = new JLabel(getLabelFor(prefix + START)); c.gridx++; c.weightx = 0; this.add(labelAvoirStart, c); c.gridx++; c.weightx = 1; final JTextField fieldStart = new JTextField(); this.add(fieldStart, c); final JLabel labelResult = new JLabel(); c.gridx++; c.weightx = 0; this.add(labelResult, c); if (getTable().getFieldsName().contains(prefix + AUTO_MONTH)) { final JCheckBox boxAuto = new JCheckBox(getLabelFor(prefix + AUTO_MONTH)); c.gridx++; c.weightx = 0; this.add(boxAuto, c); this.addSQLObject(boxAuto, prefix + AUTO_MONTH); } // Affichage dynamique du rsultat SimpleDocumentListener listener = new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { updateLabel(fieldStart, fieldFormat, labelResult); } }; fieldFormat.getDocument().addDocumentListener(listener); fieldStart.getDocument().addDocumentListener(listener); this.addRequiredSQLObject(fieldFormat, prefix + FORMAT); this.addRequiredSQLObject(fieldStart, prefix + START); } } // JLabel labelCodeLettrage = new JLabel(getLabelFor("CODE_LETTRAGE")); // c.gridy++; // c.gridx = 0; // c.weightx = 0; // this.add(labelCodeLettrage, c); // c.gridx++; // c.weightx = 1; // this.add(this.textCodeLettrage, c); // // c.gridx++; // c.weightx = 0; // labelNextCodeLettrage = new JLabel(); // this.add(labelNextCodeLettrage, c); JLabel labelExemple = new JLabel("Exemple de format : 'Fact'yyyy0000"); c.gridy++; c.gridx = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 1; c.anchor = GridBagConstraints.NORTHWEST; this.add(labelExemple, c); // this.textCodeLettrage.getDocument().addDocumentListener(this.listenText); } // private void updateLabelNextCode() { // String s = getNextCodeLetrrage(this.textCodeLettrage.getText()); // this.labelNextCodeLettrage.setText(donne + " " + s); // } private void updateLabel(JTextField textStart, JTextField textFormat, JLabel label) { if (textStart.getText().trim().length() > 0) { try { String numProposition = getNextNumero(textFormat.getText(), Integer.parseInt(textStart.getText()), new Date()); if (numProposition != null) { label.setText(" --> " + numProposition); label.setIcon(null); } else { label.setIcon(this.iconWarning); label.setText(""); } } catch (IllegalArgumentException e) { JOptionPane.showMessageDialog(null, "Le format " + textFormat.getText() + " n'est pas valide!"); } } else { label.setIcon(this.iconWarning); label.setText(""); } } }; }
From source file:org.openconcerto.task.TodoListPanel.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) this.renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);/*w w w . j a v a2 s .c o m*/ label.setIcon(this.icon); label.setBorder(BorderFactory.createEmptyBorder()); label.setIconTextGap(0); label.setHorizontalTextPosition(0); label.setHorizontalAlignment(SwingConstants.CENTER); return label; }
From source file:org.openmicroscopy.shoola.agents.measurement.util.ui.ResultsCellRenderer.java
/** * Adds the appropriate shape icon to the label. * // w w w. j a va 2 s. com * @param shape above. */ private JComponent makeShapeIcon(JLabel label, String shape) { if (FigureUtil.SCRIBBLE_TYPE.equals(shape)) label.setIcon(SCRIBBLE); else if (FigureUtil.LINE_TYPE.equals(shape)) label.setIcon(LINE); else if (FigureUtil.LINE_CONNECTION_TYPE.equals(shape)) label.setIcon(CONNECTION); else if (FigureUtil.POLYGON_TYPE.equals(shape)) label.setIcon(POLYGON); else if (FigureUtil.POINT_TYPE.equals(shape)) label.setIcon(POINT); else if (FigureUtil.RECTANGLE_TYPE.equals(shape)) label.setIcon(RECTANGLE); else if (FigureUtil.ELLIPSE_TYPE.equals(shape)) label.setIcon(ELLIPSE); else if (FigureUtil.TEXT_TYPE.equals(shape)) label.setIcon(TEXT); else if (FigureUtil.MASK_TYPE.equals(shape)) label.setIcon(MASK); else label.setText(shape); if (label.getIcon() != null) { JPanel p = new JPanel(); FlowLayout layout = new FlowLayout(FlowLayout.CENTER); layout.setVgap(0); p.setBorder(BorderFactory.createEmptyBorder()); p.setLayout(layout); p.setOpaque(true); p.setBackground(getBackground()); p.add(label); return p; } return label; }
From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.util.RepositoryEntryCellRenderer.java
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) { final JLabel component = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);//from w ww. ja v a 2 s . c o m try { if (column == 0) { final RepositoryTableModel tableModel = (RepositoryTableModel) table.getModel(); final RowSorter rowSorter = table.getRowSorter(); final FileObject e; if (rowSorter != null) { e = tableModel.getElementForRow(rowSorter.convertRowIndexToModel(row)); } else { e = tableModel.getElementForRow(row); } if (e.getType() == FileType.FOLDER) { component.setIcon(closedIcon); } else { component.setIcon(leafIcon); } } else { component.setIcon(null); } } catch (FileSystemException fse) { // ok, ugly, but not fatal. } return component; }
From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.util.RepositoryTreeCellRenderer.java
public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { final JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);/*www . jav a2 s . c om*/ if (value instanceof FileObject) { final FileObject node = (FileObject) value; try { if (leaf && (node.getType() == FileType.FOLDER)) { component.setIcon(getOpenIcon()); } } catch (FileSystemException fse) { // ignore exception here } component.setText(node.getName().getBaseName()); } else { component.setText("/"); component.setIcon(getOpenIcon()); } return component; }