List of usage examples for javax.swing JLabel setText
@BeanProperty(preferred = true, visualUpdate = true, description = "Defines the single line of text this component will display.") public void setText(String text)
From source file:org.nuclos.client.dbtransfer.DBTransferImport.java
private PanelWizardStep newStep5(final MainFrameTab ifrm) { final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); final JLabel lbResult = new JLabel(); final JEditorPane editLog = new JEditorPane(); final JScrollPane scrollLog = new JScrollPane(editLog); final JLabel lbStructureChangeResult = new JLabel( localeDelegate.getMessage("dbtransfer.import.step5.1", "\u00c4nderungen am Datenbankschema")); final JButton btnSaveStructureChangeScript = new JButton( localeDelegate.getMessage("dbtransfer.import.step5.2", "Script speichern") + "..."); final JButton btnSaveStructureChangeLog = new JButton( localeDelegate.getMessage("dbtransfer.import.step5.3", "Log speichern") + "..."); editLog.setContentType("text/html"); editLog.setEditable(false);//from ww w. ja v a2s .co m final PanelWizardStep step = new PanelWizardStep( localeDelegate.getMessage("dbtransfer.import.step5.4", "Ergebnis"), localeDelegate.getMessage( "dbtransfer.import.step5.5", "Hier wird Ihnen das Ergebnis des Imports angezeigt.")) { @Override public void prepare() { if (!importTransferResult.hasWarnings() && !importTransferResult.hasCriticals()) { lbResult.setText(localeDelegate.getMessage("dbtransfer.import.step5.6", "Import erfolgreich!")); this.setComplete(true); } else { lbResult.setText( localeDelegate.getMessage("dbtransfer.import.step5.7", "Ein Problem ist aufgetreten!")); blnSaveOfLogRecommend = true; } StringBuffer sbLog = new StringBuffer(); sbLog.append("<html><body>"); if (!importTransferResult.foundReferences.isEmpty()) { sbLog.append(localeDelegate.getMessage("dbtransfer.import.step5.8", "Folgende Konfigurationsobjekte sollten entfernt werden, werden aber noch verwendet") + ":<br />"); for (Pair<String, String> reference : importTransferResult.foundReferences) { sbLog.append( "- " + reference.y + " (" + localeDelegate.getLabelFromMetaDataVO( MetaDataClientProvider.getInstance().getEntity(reference.x)) + ")<br />"); } sbLog.append("<br />" + localeDelegate.getMessage("dbtransfer.import.step5.9", "Passen Sie Ihre Konfiguration dahingehend an oder bearbeiten Sie die Daten,\nwelche noch auf die Konfigurationsobjekte verweisen.")); sbLog.append("<br />"); } sbLog.append("<font color=\"#800000\">" + importTransferObject.result.getCriticals() + "</font>" + (importTransferObject.result.hasCriticals() ? "<br />" : "")); sbLog.append(importTransferResult.getWarnings()); sbLog.append("</body></html>"); editLog.setText(sbLog.toString()); } }; utils.initJPanel(step, new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }, new double[] { 20, TableLayout.FILL, TableLayout.PREFERRED }); step.add(lbResult, "0,0,3,0"); step.add(scrollLog, "0,1,3,1"); step.add(lbStructureChangeResult, "0,2"); step.add(btnSaveStructureChangeScript, "1,2"); step.add(btnSaveStructureChangeLog, "2,2"); btnSaveStructureChangeScript.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { UIUtils.showWaitCursorForFrame(ifrm, true); final StringBuffer sbSql = new StringBuffer(); org.apache.commons.collections.CollectionUtils.forAllDo(importTransferResult.script, new Closure() { @Override public void execute(Object element) { sbSql.append("<DDL>" + element + "</DDL>\n\n"); } }); final JFileChooser filechooser = utils.getFileChooser( localeDelegate.getMessage("configuration.transfer.file.sql", "SQL-Dateien"), ".import-sql.txt"); filechooser.setSelectedFile(new File(tfTransferFile.getText() + ".import-sql.txt")); final int iBtn = filechooser.showSaveDialog(step); if (iBtn == JFileChooser.APPROVE_OPTION) { final File file = filechooser.getSelectedFile(); if (file != null) { String fileName = file.getPath(); if (!fileName.toLowerCase().endsWith(".import-sql.txt")) { fileName += ".import-sql.txt"; } File outFile = new File(fileName); final Writer out = new BufferedWriter(new FileWriter(outFile)); try { out.write(sbSql.toString()); } finally { out.close(); } if (blnSaveOfScriptRecommend) { step.setComplete(true); } } } } catch (Exception e) { Errors.getInstance().showExceptionDialog(ifrm, e); } finally { UIUtils.showWaitCursorForFrame(ifrm, false); } } }); btnSaveStructureChangeLog.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { UIUtils.showWaitCursorForFrame(ifrm, true); final JFileChooser filechooser = utils.getFileChooser( localeDelegate.getMessage("configuration.transfer.file.log", "Log-Dateien"), ".import-log.html"); filechooser.setSelectedFile(new File(tfTransferFile.getText() + ".import-log.html")); final int iBtn = filechooser.showSaveDialog(step); if (iBtn == JFileChooser.APPROVE_OPTION) { final File file = filechooser.getSelectedFile(); if (file != null) { String fileName = file.getPath(); if (!fileName.toLowerCase().endsWith(".import-log.html")) { fileName += ".import-log.html"; } File outFile = new File(fileName); final Writer out = new BufferedWriter(new FileWriter(outFile)); try { out.write(editLog.getText()); } finally { out.close(); } if (blnSaveOfLogRecommend) { step.setComplete(true); } } } } catch (Exception e) { Errors.getInstance().showExceptionDialog(ifrm, e); } finally { UIUtils.showWaitCursorForFrame(ifrm, false); } } }); return step; }
From source file:org.nuclos.client.ui.collect.searcheditor.SearchEditorController.java
private void setupSearchEditorPanel() { // enable drag (as in "drag&drop"): setupDataTransfer(pnl.getTree());//from w ww.j a v a2 s. c o m addMouseListenerTo(pnl.getTree()); pnl.getTree().setCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object oValue, boolean bSelected, boolean bExpanded, boolean bLeaf, int iRow, boolean bHasFocus) { final JLabel result = (JLabel) super.getTreeCellRendererComponent(tree, oValue, bSelected, bExpanded, bLeaf, iRow, bHasFocus); final SearchConditionTreeNode node = (SearchConditionTreeNode) oValue; result.setText(node.getLabel(bExpanded)); return result; } }); pnl.getSimplifyButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { pnl.setSearchCondition(SearchConditionUtils.simplified(pnl.getSearchCondition())); } }); }
From source file:org.nuclos.client.ui.JInfoTabbedPane.java
private void updateTab(int tab) { if (tab >= getTabCount()) return;//from ww w . j a v a2 s .c o m final JLabel label = (JLabel) getTabComponentAt(tab); final String title = tabTitles.get(tab); String text; if (displayTabInfo.get(tab)) { final Integer info = tabInfo.get(tab); if (info == null) { text = title + " *"; } else { int j = info.intValue(); if (j < 0) { if (j > -1000) { text = title + " (" + j + ")"; } else { text = title + " -?"; } } else if (j > 999) { text = title + " (>999)"; } else { text = title + " (" + j + ")"; } } } else { text = title; } text = getMnemonicTextIfAny(text, tab); label.setText(text); }
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()); };/* w w w .j a v a 2 s . co m*/ }); 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.erp.core.finance.accounting.ui.GrandLivrePanel.java
/** * Cre le panel d'un onglet associ une classe * /*w w w . j a va 2 s . c o m*/ * @param cc ClasseCompte la classe des comptes * @return JPanel le JPanel associ */ private JPanel initClassePanel(ClasseCompte cc) { final JPanel panelTmp = new JPanel(); long totalDebitClasse = 0; long totalCreditClasse = 0; panelTmp.setLayout(new GridBagLayout()); panelTmp.setOpaque(false); final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 1; c.weighty = 0; // Rcupration des comptes de la classe avec le total SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete(); SQLTable compteTable = base.getTable("COMPTE_PCE"); SQLTable ecritureTable = base.getTable("ECRITURE"); SQLSelect sel = new SQLSelect(base); sel.addSelect(compteTable.getKey()); sel.addSelect(compteTable.getField("NUMERO")); sel.addSelect(compteTable.getField("NOM")); sel.addSelect(ecritureTable.getField("DEBIT"), "SUM"); sel.addSelect(ecritureTable.getField("CREDIT"), "SUM"); String function = "REGEXP"; String match = cc.getTypeNumeroCompte(); if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) { // function = "SIMILAR TO"; function = "~"; // match = cc.getTypeNumeroCompte().replace(".*", "%"); } Where w = new Where(compteTable.getField("NUMERO"), function, match); Where w2 = new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=", compteTable.getKey()); if (!UserManager.getInstance().getCurrentUser().getRights() .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) { // TODO Show Restricted acces in UI w = w.and(new Where(ecritureTable.getField("COMPTE_NUMERO"), "LIKE", "411%")); } sel.setWhere(w.and(w2)); String req = sel.asString() + " GROUP BY \"COMPTE_PCE\".\"ID\",\"COMPTE_PCE\".\"NUMERO\",\"COMPTE_PCE\".\"NOM\" ORDER BY \"COMPTE_PCE\".\"NUMERO\""; System.out.println(req); Object ob = base.getDataSource().execute(req, new ArrayListHandler()); List myList = (List) ob; JLabel labelTotalClasse = new JLabel(); labelTotalClasse.setOpaque(false); if (myList.size() != 0) { /*************************************************************************************** * Cration des Panels de chaque compte **************************************************************************************/ // c.weighty = 1; for (int i = 0; i < myList.size(); i++) { Object[] objTmp = (Object[]) myList.get(i); final Compte compteTmp = new Compte(((Number) objTmp[0]).intValue(), objTmp[1].toString(), objTmp[2].toString(), "", ((Number) objTmp[3]).longValue(), ((Number) objTmp[4]).longValue()); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.weighty = 0; c.gridx = 0; c.gridy++; panelTmp.add(creerComptePanel(compteTmp), c); // calcul du total de la classe totalDebitClasse += compteTmp.getTotalDebit(); totalCreditClasse += compteTmp.getTotalCredit(); } // Total de la classe labelTotalClasse.setText( "Total Classe " + cc.getNom() + " Dbit : " + GestionDevise.currencyToString(totalDebitClasse) + " Crdit : " + GestionDevise.currencyToString(totalCreditClasse)); } else { labelTotalClasse.setHorizontalAlignment(SwingConstants.CENTER); labelTotalClasse.setText("Aucune criture pour la classe " + cc.getNom()); } c.gridy++; c.weighty = 1; panelTmp.add(labelTotalClasse, c); return panelTmp; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.SuppressionEcrituresPanel.java
public SuppressionEcrituresPanel(final int idMvt) { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); c.weightx = 1;// www. ja v a2s .c om SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete(); SQLTable tableMouvement = base.getTable("MOUVEMENT"); SQLRow rowMvt = tableMouvement.getRow(idMvt); JLabel label = new JLabel("Vous allez supprimer la pice n" + rowMvt.getInt("ID_PIECE")); JLabelWarning warning = new JLabelWarning(); JPanel panelLabel = new JPanel(); panelLabel.add(warning); panelLabel.add(label); c.gridwidth = GridBagConstraints.REMAINDER; this.add(panelLabel, c); // TODO afficher les numeros de mouvement implique int[] idS = getMouvement(rowMvt.getInt("ID_PIECE")); if (idS == null) { ExceptionHandler.handle("Aucun mouvement associ la pice n" + ((rowMvt != null) ? rowMvt.getInt("ID_PIECE") : "mouvement nul")); } else { StringBuffer s = new StringBuffer(); s.append("Elle est compose par les mouvements : ("); JLabel labelMouv = new JLabel(); // c.gridwidth = 1; c.gridy++; c.gridx = 0; this.add(labelMouv, c); s.append(idS[0]); for (int i = 1; i < idS.length; i++) { s.append(", "); s.append(idS[i]); } s.append(')'); labelMouv.setText(s.toString()); } JButton buttonOK = new JButton("OK"); JButton buttonCancel = new JButton("Annuler"); c.gridwidth = 1; c.gridy++; c.gridx = 0; this.add(buttonOK, c); c.gridx++; this.add(buttonCancel, c); buttonOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { EcritureSQLElement elt = (EcritureSQLElement) Configuration.getInstance().getDirectory() .getElement("ECRITURE"); elt.archiveMouvement(idMvt); ((JFrame) SwingUtilities.getRoot(SuppressionEcrituresPanel.this)).dispose(); } }); buttonCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ((JFrame) SwingUtilities.getRoot(SuppressionEcrituresPanel.this)).dispose(); } }); }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java
/** * Builds and lays out the pixels size options. * /*from ww w .j a v a 2s. c o m*/ * @return See above. */ private JPanel buildPixelSizeComponent() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.setBorder(BorderFactory.createTitledBorder("Pixels Size Defaults")); JLabel l = new JLabel(); l.setText("Used if no values included in the file:"); p.add(UIUtilities.buildComponentPanel(l)); JPanel row = new JPanel(); row.setLayout(new FlowLayout(FlowLayout.LEFT)); l = new JLabel(); l.setText("X: "); row.add(l); row.add(pixelsSize.get(0)); l = new JLabel(); l.setText("Y: "); row.add(l); row.add(pixelsSize.get(1)); l = new JLabel(); l.setText("Z: "); row.add(l); row.add(pixelsSize.get(2)); p.add(row); return UIUtilities.buildComponentPanel(p); }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.ImportDialog.java
/** * Builds the component hosting the controls to add annotations. * /*from w w w. j a v a 2s .co m*/ * @return See above. */ private JPanel buildAnnotationComponent() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); JLabel l = new JLabel(); l.setText("Add tag to images"); JPanel tagPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); tagPanel.add(l); tagPanel.add(tagButton); l = new JLabel(); l.setText(": "); tagPanel.add(l); tagPanel.add(tagsPane); p.add(tagPanel); return UIUtilities.buildComponentPanel(p); }
From source file:org.openmicroscopy.shoola.agents.measurement.util.ui.ResultsCellRenderer.java
/** * Adds the appropriate shape icon to the label. * /*from w w w . j av a 2s . c om*/ * @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.openmicroscopy.shoola.agents.measurement.util.ui.ResultsCellRenderer.java
/** * @see TableCellRenderer#getTableCellRendererComponent(JTable, Object, * boolean, boolean, int, int) *///from www .j ava 2 s. c o m public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component thisComponent = new JLabel(); JLabel label = new JLabel(); label.setOpaque(true); if (value instanceof Number) { MeasurementTableModel tm = (MeasurementTableModel) table.getModel(); KeyDescription key = tm.getColumnNames().get(column); String k = key.getKey(); MeasurementUnits units = tm.getUnitsType(); Number n = (Number) value; String s; if (units.isInMicrons()) { UnitsObject object; StringBuffer buffer = new StringBuffer(); object = UIUtilities.transformSize(n.doubleValue()); s = twoDecimalPlaces(object.getValue()); if (StringUtils.isNotBlank(s)) { buffer.append(s); if (!(AnnotationKeys.ANGLE.getKey().equals(k) || AnnotationDescription.ZSECTION_STRING.equals(k) || AnnotationDescription.ROIID_STRING.equals(k) || AnnotationDescription.TIME_STRING.equals(k))) { buffer.append(object.getUnits()); } if (AnnotationKeys.AREA.getKey().equals(k)) { buffer = new StringBuffer(); object = UIUtilities.transformSquareSize(n.doubleValue()); s = twoDecimalPlaces(object.getValue()); buffer.append(s); buffer.append(object.getUnits()); } label.setText(buffer.toString()); } } else { s = UIUtilities.twoDecimalPlaces(n.doubleValue()); if (StringUtils.isNotBlank(s)) { label.setText(s); } } thisComponent = label; } else if (value instanceof FigureType || value instanceof String) { thisComponent = makeShapeIcon(label, "" + value); } else if (value instanceof Color) { label.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY)); label.setBackground((Color) value); thisComponent = label; } else if (value instanceof Boolean) { JCheckBox checkBox = new JCheckBox(); checkBox.setSelected((Boolean) value); thisComponent = checkBox; } else if (value instanceof ArrayList) { thisComponent = createList(value); //return list; } if (!(value instanceof Color)) { RendererUtils.setRowColor(thisComponent, table.getSelectedRow(), row); if (label != null) label.setBackground(thisComponent.getBackground()); } return thisComponent; }