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:SeedGenerator.MainForm.java
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); final JLabel directoryLabel = new JLabel(" "); directoryLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 36)); contentPane.add(directoryLabel, BorderLayout.NORTH); final JLabel filenameLabel = new JLabel(" "); filenameLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 36)); contentPane.add(filenameLabel, BorderLayout.SOUTH); JFileChooser fileChooser = new JFileChooser("."); fileChooser.setControlButtonsAreShown(true); contentPane.add(fileChooser, BorderLayout.CENTER); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JFileChooser theFileChooser = (JFileChooser) actionEvent.getSource(); String command = actionEvent.getActionCommand(); if (command.equals(JFileChooser.APPROVE_SELECTION)) { File selectedFile = theFileChooser.getSelectedFile(); directoryLabel.setText(selectedFile.getParent()); filenameLabel.setText(selectedFile.getName()); } else if (command.equals(JFileChooser.CANCEL_SELECTION)) { directoryLabel.setText(" "); filenameLabel.setText(" "); }// www. j a v a 2 s . c o m frame.setVisible(false); } }; fileChooser.addActionListener(actionListener); frame.pack(); frame.setVisible(true); // TODO add your handling code here: }
From source file:slash.navigation.converter.gui.renderer.ExifColumnTableCellRenderer.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) { JLabel label = JLabel.class.cast( super.getTableCellRendererComponent(table, value, isSelected, hasFocus, rowIndex, columnIndex)); PhotoPosition position = PhotoPosition.class.cast(value); String exposure = position.getExposure() != null ? position.getExposure().numerator + "/" + position.getExposure().divisor : "?"; String text = MessageFormat.format(RouteConverter.getBundle().getString("exif-data"), formatDate(position.getTime(), UTC_TIMEZONE_ID), formatTime(position.getTime(), UTC_TIMEZONE_ID), formatString(position.getMake()), formatString(position.getModel()), formatString(position.getWidth()), formatString(position.getHeight()), formatString(position.getfNumber()), exposure, formatString(position.getFocal()), getFlash(position.getFlash()), formatString(position.getPhotographicSensitivity())); label.setText(text); label.setVerticalAlignment(TOP);/*from ww w . j a va2 s . c om*/ return label; }
From source file:storybook.ui.table.renderer.AttributesTableCellRenderer.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString()); JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);//from w w w .jav a 2s . com if (value == null || value instanceof String) { return lbText; } try { @SuppressWarnings("unchecked") List<Attribute> list = (List<Attribute>) value; if (list == null || list.isEmpty()) { return lbText; } try { lbText.setText(StringUtils.join(list, ", ")); } catch (NullPointerException e) { // ignore } } catch (LazyInitializationException lie) { BookModel model = mainFrame.getBookModel(); Session session = model.beginTransaction(); @SuppressWarnings("unchecked") List<Attribute> list = (List<Attribute>) value; try { for (Attribute property : list) { session.refresh(property); } lbText.setText(StringUtils.join(list, ", ")); model.commit(); } catch (Exception e) { // ignore // e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } return lbText; }
From source file:storybook.ui.table.renderer.ItemsTableCellRenderer.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);/*from w w w . ja v a 2 s . c o m*/ if (value instanceof String) { return lbText; } @SuppressWarnings("unchecked") List<Item> list = (List<Item>) value; try { lbText.setText(StringUtils.join(list, ", ")); } catch (LazyInitializationException lie) { MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString()); BookModel model = mainFrame.getBookModel(); Session session = model.beginTransaction(); for (Item item : list) { session.refresh(item); } lbText.setText(StringUtils.join(list, ", ")); model.commit(); } catch (Exception e) { e.printStackTrace(); } return lbText; }
From source file:storybook.ui.table.renderer.LocationsTableCellRenderer.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);// www. ja v a 2 s . c o m if (value instanceof String) { return lbText; } else { @SuppressWarnings("unchecked") List<Location> list = (List<Location>) value; try { lbText.setText(StringUtils.join(list, ", ")); } catch (LazyInitializationException lie) { MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString()); BookModel model = mainFrame.getBookModel(); Session session = model.beginTransaction(); for (Location location : list) { session.refresh(location); } lbText.setText(StringUtils.join(list, ", ")); model.commit(); } catch (Exception e) { e.printStackTrace(); } } return lbText; }
From source file:storybook.ui.table.renderer.PersonsTableCellRenderer.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);/* w ww . j a va 2s.c om*/ if (value instanceof String) { return lbText; } @SuppressWarnings("unchecked") List<Person> list = (List<Person>) value; List<String> abbrList = new ArrayList<String>(); try { for (Person person : list) { abbrList.add(person.getAbbr()); // CleverLabel lb = new CleverLabel(person.getAbbr()); // lb.setBackground(person.getJColor()); // panel.add(lb); } } catch (LazyInitializationException lie) { MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString()); BookModel model = mainFrame.getBookModel(); Session session = model.beginTransaction(); for (Person person : list) { session.refresh(person); abbrList.add(person.getAbbr()); } model.commit(); } catch (Exception e) { e.printStackTrace(); return lbText; } lbText.setText(" " + StringUtils.join(abbrList, ", ")); return lbText; }
From source file:storybook.ui.table.renderer.StrandsTableCellRenderer.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString()); JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);//from www . j a v a2s . c om if (value instanceof String) { return lbText; } List<String> abbrList = new ArrayList<String>(); try { @SuppressWarnings("unchecked") List<Strand> list = (List<Strand>) value; for (Strand strand : list) { abbrList.add(strand.getAbbr()); } } catch (LazyInitializationException lie) { BookModel model = mainFrame.getBookModel(); Session session = model.beginTransaction(); @SuppressWarnings("unchecked") List<Strand> list = (List<Strand>) value; for (Strand strand : list) { session.refresh(strand); abbrList.add(strand.getAbbr()); } model.commit(); } catch (Exception e) { e.printStackTrace(); return lbText; } lbText.setText(" " + StringUtils.join(abbrList, ", ")); return lbText; }
From source file:tufts.vue.ui.InspectorPane.java
private void loadText(JLabel c, String text) { String hasText = c.getText(); // This prevents flashing where fields of // length greater the the visible area do // a flash-scroll when setting the text, even // if it's the same as what's there. if (hasText != text && !hasText.equals(text)) c.setText(text); }
From source file:tvbrowser.ui.mainframe.MainFrame.java
/** * Search for updates of plugins.//from w w w . j a va 2 s. com * * @param baseUrl The url string to load the plugin updates from. * @param showOnlyUpdates If the dialog is only to show when updates of * installed plugins are found. * @param infoLabel The label to use to show infos. * @param dontShowUpdateDlg If the dialog should not be shown even if updates * are available. (User has disabled automatically plugin updates.) */ public void updatePlugins(final String baseUrl, final boolean showOnlyUpdates, final JLabel infoLabel, final boolean dontShowUpdateDlg) { new Thread("Plugin Update Thread") { public void run() { try { infoLabel.setText(mLocalizer.msg("searchForPluginUpdates", "Search for plugin updates...")); java.net.URL url = new java.net.URL(baseUrl + "/" + PluginAutoUpdater.PLUGIN_UPDATES_FILENAME); SoftwareUpdater softwareUpdater = new SoftwareUpdater(url, showOnlyUpdates, false); mSoftwareUpdateItems = softwareUpdater.getAvailableSoftwareUpdateItems(); infoLabel.setText(""); } catch (java.io.IOException e) { e.printStackTrace(); } if (!dontShowUpdateDlg) { if (mSoftwareUpdateItems == null && !showOnlyUpdates) { JOptionPane.showMessageDialog(UiUtilities.getLastModalChildOf(MainFrame.getInstance()), mLocalizer.msg("error.1", "software check failed.")); } else if (mSoftwareUpdateItems != null && mSoftwareUpdateItems.length == 0 && !showOnlyUpdates) { JOptionPane.showMessageDialog(UiUtilities.getLastModalChildOf(MainFrame.getInstance()), mLocalizer.msg("error.2", "No new items available")); } else if (mSoftwareUpdateItems != null && mSoftwareUpdateItems.length > 0) { Window parent = UiUtilities.getLastModalChildOf(MainFrame.getInstance()); SoftwareUpdateDlg dlg = new SoftwareUpdateDlg(parent, baseUrl, showOnlyUpdates, mSoftwareUpdateItems); //dlg.setSoftwareUpdateItems(mSoftwareUpdateItems); dlg.setLocationRelativeTo(parent); dlg.setVisible(true); } } BlockedPlugin[] newlyBlocked = Settings.propBlockedPluginArray.getNewBlockedPlugins(); if (newlyBlocked != null && newlyBlocked.length > 0) { StringBuilder message = new StringBuilder(); for (BlockedPlugin blockedPlugin : newlyBlocked) { PluginProxy plugin = PluginProxyManager.getInstance() .getPluginForId(blockedPlugin.getPluginId()); if (plugin == null) { TvDataServiceProxy dataService = TvDataServiceProxyManager.getInstance() .findDataServiceById(blockedPlugin.getPluginId()); if (dataService != null && blockedPlugin.isBlockedVersion(dataService.getId(), dataService.getInfo().getVersion())) { message.append("\n").append(dataService.getInfo().getName()).append(" (") .append(blockedPlugin.getBlockStart()).append(" - ") .append(blockedPlugin.getBlockEnd()).append(")"); } } else if (blockedPlugin.isBlockedVersion(plugin)) { message.append("\n").append(plugin.getInfo().getName()).append(" (") .append(blockedPlugin.getBlockStart()).append(" - ") .append(blockedPlugin.getBlockEnd()).append(")"); } } if (message.length() > 0) { message.insert(0, mLocalizer.msg("update.blockedInfo", "The following Plugins were blocked and cannot be used in their current version:\n")); showInfoTextMessage(mLocalizer.msg("update.blockedPlugins", "Plugins blocked!"), message.toString(), 450); } } Settings.propLastPluginsUpdate.setDate(Date.getCurrentDate()); infoLabel.setText(""); mSoftwareUpdateItems = null; } }.start(); }
From source file:uk.ac.ebi.mnb.dialog.tools.DownloadStructuresDialog.java
@Override public JLabel getDescription() { JLabel label = super.getDescription(); label.setText("Retrieve structures for selected metabolites"); return label; }