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:ca.phon.app.project.RecentProjectListCellRenderer.java
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); // comp.setVerticalTextPosition(JLabel.BOTTOM); // comp.setHorizontalTextPosition(JLabel.CENTER); // if the file string stats with RMI, show the remote project icon, // otherwise, show the default project icon if (value.toString().startsWith("rmi://")) comp.setIcon(remoteProjectIcon); else/* w w w . j a va 2 s. co m*/ comp.setIcon(localProjectIcon); int numChars = 20; int numBreaks = value.toString().length() / numChars; // String compString = new String(); // for(int i = 0; i < numBreaks; i++) { // compString += value.toString().substring(i*numChars, i*numChars+numChars) + "<br>"; // } // compString += value.toString().substring(numBreaks*numChars, // value.toString().length()); comp.setText("<html><center>" + StringUtils.abbreviate(value.toString(), 60) + "</center></html>"); return comp; }
From source file:com.diversityarrays.kdxplore.curate.TraitInstanceCellRenderer.java
private void initIcon(JLabel label, Object value) { Icon icon = null;//from ww w .jav a 2 s . c o m if (value instanceof TraitInstance) { TraitInstance ti = (TraitInstance) value; if (TRAIT_TO_EDIT == ti) { label.setText("Trait to Edit"); } else { icon = traitColorProvider.getTraitLegendTile(ti); label.setText(instanceNameTransformer.transform(ti)); } } label.setIcon(icon); }
From source file:es.emergya.ui.base.plugins.PluggableJTabbedPane.java
private void addFloatingButtons() { JButton salir = new JButton(); salir.addActionListener(new ExitHandler()); Icon icon = LogicConstants.getIcon("header_button_exit"); salir.setIcon(icon);//from w ww . j a v a 2s. c o m if (icon != null) if (min_height < icon.getIconHeight()) min_height = icon.getIconHeight(); // Aadimos el botn de Salir salir.setBounds(this.getWidth() - icon.getIconWidth() - 2, 2, icon.getIconWidth(), icon.getIconHeight()); salir.setBorderPainted(false); PluggableJTabbedPane.this.salir = salir.getBounds(); // Logo de la empresa JLabel logo = new JLabel(); icon = LogicConstants.getIcon("header_logo_cliente"); if (min_height < icon.getIconHeight()) min_height = icon.getIconHeight(); logo.setIcon(icon); logo.setBounds(salir.getBounds().x - icon.getIconWidth() - 2, 2, icon.getIconWidth(), icon.getIconHeight()); JLabel companyLogo = new JLabel(); icon = LogicConstants.getIcon("header_logo"); if (icon != null) if (min_height < icon.getIconHeight()) min_height = icon.getIconHeight(); companyLogo.setIcon(icon); companyLogo.setBounds(logo.getBounds().x - icon.getIconWidth(), 2, icon.getIconWidth(), icon.getIconHeight()); botones_flotantes = new ArrayList<JComponent>(); addFloatingButton(companyLogo); addFloatingButton(logo); addFloatingButton(salir); repaint(); }
From source file:com.ssn.event.controller.SSNShareController.java
@Override public void mouseEntered(MouseEvent e) { Object mouseEventObj = e.getSource(); if (mouseEventObj != null && mouseEventObj instanceof JLabel) { JLabel jLbl = (JLabel) mouseEventObj; if (jLbl.getName().equalsIgnoreCase("FacebookSharing")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/fb-hover.png"))); } else if (jLbl.getName().equalsIgnoreCase("TwitterSharing")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/twitter-hover.png"))); } else if (jLbl.getName().equalsIgnoreCase("moveCopy")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/move-hover.png"))); } else if (jLbl.getName().equalsIgnoreCase("MailSharing")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/mail-hover.png"))); }//from w w w .j a va 2 s .co m } }
From source file:com.ssn.event.controller.SSNShareController.java
@Override public void mouseExited(MouseEvent e) { Object mouseEventObj = e.getSource(); if (mouseEventObj != null && mouseEventObj instanceof JLabel) { JLabel jLbl = (JLabel) mouseEventObj; if (jLbl.getName().equalsIgnoreCase("FacebookSharing")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/fb-normal.png"))); } else if (jLbl.getName().equalsIgnoreCase("TwitterSharing")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/twitter-normal.png"))); } else if (jLbl.getName().equalsIgnoreCase("moveCopy")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/move-normal.png"))); } else if (jLbl.getName().equalsIgnoreCase("MailSharing")) { jLbl.setIcon(new ImageIcon(getClass().getResource("/icon/mail-normal.png"))); }// w w w . j av a2 s . c om } }
From source file:gdt.jgui.tool.JIconSelector.java
/** * Create the context./*w w w .j a v a 2 s. c o m*/ * @param console the main console. * @param locator$ the locator string. * @return the procedure context. */ @Override public JContext instantiate(JMainConsole console, String locator$) { this.console = console; try { panel.removeAll(); Properties locator = Locator.toProperties(locator$); entihome$ = locator.getProperty(Entigrator.ENTIHOME); entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); entityLabel$ = locator.getProperty(EntityHandler.ENTITY_LABEL); requesterResponseLocator$ = locator.getProperty(JRequester.REQUESTER_RESPONSE_LOCATOR); // System.out.println("IconSelector:instantiate:locator="+locator$); Entigrator entigrator = console.getEntigrator(entihome$); String icons$ = entigrator.ent_getHome(Entigrator.ICONS); File icons = new File(icons$); File[] fa = icons.listFiles(); if (fa == null) return this; ImageIcon icon; JLabel label; Image img; for (File aFa : fa) { icon = new ImageIcon(aFa.getPath()); img = icon.getImage(); img = img.getScaledInstance(smallIcon, smallIcon, java.awt.Image.SCALE_SMOOTH); icon = new ImageIcon(img); label = new JLabel(); label.setIcon(icon); label.setName(aFa.getName()); label.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { try { JLabel label = (JLabel) me.getSource(); icon$ = label.getName(); byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); responseLocator$ = Locator.append(responseLocator$, ICON, icon$); JConsoleHandler.execute(JIconSelector.this.console, responseLocator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); panel.add(label); } } catch (Exception e) { LOGGER.severe(e.toString()); } return this; }
From source file:com.enderville.enderinstaller.ui.Installer.java
private void loadModDescription(String modName) { JPanel p = getModDescriptionPane(); p.removeAll();/*from ww w . j a v a 2s .c o m*/ p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); final String extras = InstallerConfig.getExtraModsFolder(); final String modFolderName = FilenameUtils.concat(extras, modName); File modFolder = new File(modFolderName); if (!modFolder.exists()) { LOGGER.error("Mod folder for " + modName + " does not exist."); } File descrFile = new File(FilenameUtils.concat(modFolderName, "description.txt")); File imgFile = new File(FilenameUtils.concat(modFolderName, "image.png")); if (!descrFile.exists() && !imgFile.exists()) { p.add(new JLabel("<html>No description for:<br>" + modName + "</html>")); } else { if (imgFile.exists()) { try { JLabel label = new JLabel(); BufferedImage img = ImageIO.read(imgFile); label.setIcon(new ImageIcon(img)); p.add(label); } catch (IOException e) { LOGGER.error("Error reading image file: " + imgFile.getPath(), e); } } if (descrFile.exists()) { StringBuilder buffer = new StringBuilder(); try { BufferedReader r = new BufferedReader(new FileReader(descrFile)); String l = null; while ((l = r.readLine()) != null) { buffer.append(l + "\n"); } r.close(); JEditorPane area = new JEditorPane(); area.setContentType("text/html"); area.setText(buffer.toString()); area.setEditable(false); area.addHyperlinkListener(this); area.setCaretPosition(0); p.add(new JScrollPane(area)); } catch (IOException e) { LOGGER.error("Error reading description file: " + descrFile.getPath(), e); } } } p.validate(); p.repaint(); }
From source file:com.enderville.enderinstaller.ui.Installer.java
protected void initialPanel(JPanel contentPane) { JLabel text = new JLabel(); try {//from w w w .java2s.com ImageIcon icon = new ImageIcon(ImageIO.read(new FileInputStream(InstallerConfig.getLogoFile()))); text.setIcon(icon); } catch (IOException e) { LOGGER.error("IO error on logo.png", e); } StringBuilder textBuffer = new StringBuilder(); try { BufferedReader r = new BufferedReader(new FileReader(InstallerConfig.getInitTextFile())); String line = null; while ((line = r.readLine()) != null) { textBuffer.append(line + "\n"); } } catch (IOException ioe) { LOGGER.error("IO error on logo.png", ioe); } text.setText(textBuffer.toString()); text.setVerticalTextPosition(JLabel.BOTTOM); text.setHorizontalTextPosition(JLabel.CENTER); contentPane.setLayout(new MigLayout(new LC().fill())); contentPane.add(text, new CC().alignX("center").wrap()); contentPane.add(getTargetButton(), new CC().alignX("center").wrap()); }
From source file:drusy.ui.panels.SwitchStatePanel.java
private void addUser(String hostName, String information, long txBytes, long rxBytes) { JPanel panel = new JPanel(); JLabel informationLabel = new JLabel(); ImageIcon imageIcon;//from w w w .j av a 2s . c o m //======== panel1 ======== { panel.setLayout(new BorderLayout()); panel.setBorder(new EmptyBorder(0, 10, 0, 10)); //---- label2 ---- if (hostName.equals("smartphone")) { imageIcon = Res.getImage("img/iphone-56.png"); } else { imageIcon = Res.getImage("img/mac-56.png"); } informationLabel.setIcon(imageIcon); informationLabel.setText("<html><b>" + information + "</b><br />Download: " + txBytes / 1000.0 + " ko/s <br />Upload: " + rxBytes / 1000.0 + " ko/s</html>"); informationLabel.setHorizontalAlignment(SwingConstants.CENTER); panel.add(informationLabel, BorderLayout.CENTER); } mainPanel.add(panel); adaptPanelSize(); users.add(panel); }
From source file:ComplexCellRenderer.java
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Font theFont = null;//from ww w . ja v a 2s .co m Color theForeground = null; Icon theIcon = null; String theText = null; JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof Object[]) { Object values[] = (Object[]) value; theFont = (Font) values[0]; theForeground = (Color) values[1]; theIcon = (Icon) values[2]; theText = (String) values[3]; } else { theFont = list.getFont(); theForeground = list.getForeground(); theText = ""; } if (!isSelected) { renderer.setForeground(theForeground); } if (theIcon != null) { renderer.setIcon(theIcon); } renderer.setText(theText); renderer.setFont(theFont); return renderer; }