Java Code Examples for javax.swing.Icon

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project huiswerk, under directory /print/zxing-1.6/javase/src/com/google/zxing/client/j2se/.

Source file: GUIRunner.java

  23 
vote

private void chooseImage() throws MalformedURLException {
  JFileChooser fileChooser=new JFileChooser();
  fileChooser.showOpenDialog(this);
  File file=fileChooser.getSelectedFile();
  Icon imageIcon=new ImageIcon(file.toURI().toURL());
  setSize(imageIcon.getIconWidth(),imageIcon.getIconHeight() + 100);
  imageLabel.setIcon(imageIcon);
  String decodeText=getDecodeText(file);
  textArea.setText(decodeText);
}
 

Example 2

From project addis, under directory /application/src/main/java/org/drugis/addis/gui/.

Source file: GUIFactory.java

  22 
vote

public static JButton createIconButton(final String iconName,final String toolTipText){
  suppressErrors(true);
  Icon icon=Main.IMAGELOADER.getIcon(iconName);
  if (icon == null) {
    suppressErrors(false);
    icon=MainWindow.IMAGELOADER.getIcon(iconName);
  }
  JButton button=new JButton(icon);
  button.setToolTipText(toolTipText);
  return button;
}
 

Example 3

From project Euclidean-Pattern-Generator, under directory /src/com/hisschemoller/sequencer/view/components/.

Source file: JToggleButtonForPanel.java

  22 
vote

public void paintComponent(Graphics g){
  super.paintComponent(g);
  int w=getWidth();
  int h=getHeight();
  g.setColor(getBackground());
  g.fillRect(0,0,w,h);
  g.setColor(getForeground());
  g.drawString(getText(),10,(h + g.getFontMetrics().getAscent()) / 2 - 1);
  Icon icon=isSelected() ? getSelectedIcon() : getIcon();
  icon.paintIcon(this,g,w - 30,(h - getIcon().getIconHeight()) >> 1);
}
 

Example 4

From project freemind, under directory /freemind/freemind/controller/.

Source file: StructuredMenuHolder.java

  22 
vote

private static void setSelected(JMenuItem menuItem,boolean state){
  if (state) {
    menuItem.setIcon(sSelectedIcon);
  }
 else {
    Icon normalIcon=(Icon)menuItem.getAction().getValue(Action.SMALL_ICON);
    if (normalIcon == null) {
      normalIcon=blindIcon;
    }
    menuItem.setIcon(normalIcon);
  }
}
 

Example 5

From project gradle-intellij-gui, under directory /src/main/java/org/gradle/ideaplugin/ui/.

Source file: AnimatedToolIcon.java

  22 
vote

private void updateAnimatedIcon(){
  Icon icon=icons.get(currentImageIndex);
  toolWindow.setIcon(icon);
  currentImageIndex++;
  if (currentImageIndex >= icons.size())   currentImageIndex=0;
}
 

Example 6

From project jftp, under directory /src/main/java/com/myjavaworld/jftp/.

Source file: JFTPApplet.java

  22 
vote

private void initComponents(){
  getContentPane().setLayout(new BorderLayout(0,0));
  Icon launchIcon=JFTPUtil.getIcon("launch.gif");
  butStart=new MButton(launchIcon);
  butStart.setBackground(Color.WHITE);
  butStart.setBorder(BorderFactory.createEmptyBorder());
  butStart.setPreferredSize(new Dimension(launchIcon.getIconWidth(),launchIcon.getIconHeight()));
  butStart.setMaximumSize(new Dimension(launchIcon.getIconWidth(),launchIcon.getIconHeight()));
  butStart.addActionListener(this);
  getContentPane().add(butStart,BorderLayout.CENTER);
}
 

Example 7

From project LateralGM, under directory /org/lateralgm/main/.

Source file: FileChooser.java

  22 
vote

public Icon getIcon(File f){
  for (  FileView fv : fileViews) {
    Icon val=fv.getIcon(f);
    if (val != null)     return val;
  }
  return super.getIcon(f);
}
 

Example 8

From project milton, under directory /milton/milton-client-app/src/main/java/bradswebdavclient/.

Source file: FolderPanel2.java

  22 
vote

public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus){
  Resource r=(Resource)value;
  String iconName;
  if (r instanceof Folder) {
    iconName=FolderNode.ICON_FOLDER;
  }
 else {
    iconName="/s_file.png";
  }
  Icon icon=MyCellRenderer.getIcon(iconName);
  setIcon(icon);
  setText(r.name);
  return this;
}
 

Example 9

From project milton2, under directory /milton-client-app/src/main/java/bradswebdavclient/.

Source file: FolderPanel2.java

  22 
vote

public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus){
  Resource r=(Resource)value;
  String iconName;
  if (r instanceof Folder) {
    iconName=FolderNode.ICON_FOLDER;
  }
 else {
    iconName="/s_file.png";
  }
  Icon icon=MyCellRenderer.getIcon(iconName);
  setIcon(icon);
  setText(r.name);
  return this;
}
 

Example 10

From project Mobile-Tour-Guide, under directory /zxing-2.0/javase/src/com/google/zxing/client/j2se/.

Source file: GUIRunner.java

  22 
vote

private void chooseImage() throws MalformedURLException {
  JFileChooser fileChooser=new JFileChooser();
  fileChooser.showOpenDialog(this);
  File file=fileChooser.getSelectedFile();
  Icon imageIcon=new ImageIcon(file.toURI().toURL());
  setSize(imageIcon.getIconWidth(),imageIcon.getIconHeight() + 100);
  imageLabel.setIcon(imageIcon);
  String decodeText=getDecodeText(file);
  textArea.setText(decodeText);
}
 

Example 11

From project multibit, under directory /src/main/java/org/multibit/viewsystem/swing/view/.

Source file: ImageSelection.java

  22 
vote

public Transferable createTransferable(JComponent comp){
  image=null;
  if (comp instanceof JLabel) {
    JLabel label=(JLabel)comp;
    Icon icon=label.getIcon();
    if (icon instanceof ImageIcon) {
      image=((ImageIcon)icon).getImage();
      return this;
    }
  }
  return null;
}
 

Example 12

From project TransFile, under directory /src/net/sourceforge/transfile/ui/swing/.

Source file: OperationComponent.java

  22 
vote

/** 
 * TODO doc
 * @param iconLabel <br>Should not be null <br>Input-output parameter
 */
private static final void resizeIconIfTooSmall(final JLabel iconLabel){
  final Icon icon=iconLabel.getIcon();
  if (icon.getIconWidth() < PREFERRED_FILE_ICON_SIZE) {
    final BufferedImage scaledImage=new BufferedImage(icon.getIconWidth() * FILE_ICON_SCALE,icon.getIconHeight() * FILE_ICON_SCALE,BufferedImage.TYPE_INT_ARGB);
    final Graphics2D graphics=scaledImage.createGraphics();
    graphics.scale(FILE_ICON_SCALE,FILE_ICON_SCALE);
    graphics.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
    icon.paintIcon(iconLabel,graphics,0,0);
    iconLabel.setIcon(new ImageIcon(scaledImage));
  }
}
 

Example 13

From project zxing, under directory /javase/src/com/google/zxing/client/j2se/.

Source file: GUIRunner.java

  22 
vote

private void chooseImage() throws MalformedURLException {
  JFileChooser fileChooser=new JFileChooser();
  fileChooser.showOpenDialog(this);
  File file=fileChooser.getSelectedFile();
  Icon imageIcon=new ImageIcon(file.toURI().toURL());
  setSize(imageIcon.getIconWidth(),imageIcon.getIconHeight() + 100);
  imageLabel.setIcon(imageIcon);
  String decodeText=getDecodeText(file);
  textArea.setText(decodeText);
}
 

Example 14

From project zxing-iphone, under directory /javase/src/com/google/zxing/client/j2se/.

Source file: GUIRunner.java

  22 
vote

private void chooseImage() throws MalformedURLException {
  JFileChooser fileChooser=new JFileChooser();
  fileChooser.showOpenDialog(this);
  File file=fileChooser.getSelectedFile();
  Icon imageIcon=new ImageIcon(file.toURI().toURL());
  setSize(imageIcon.getIconWidth(),imageIcon.getIconHeight() + 100);
  imageLabel.setIcon(imageIcon);
  String decodeText=getDecodeText(file);
  textArea.setText(decodeText);
}
 

Example 15

From project Calendar-Application, under directory /com/toedter/calendar/demo/.

Source file: JCalendarDemo.java

  21 
vote

/** 
 * Creates the menu bar
 * @return Description of the Return Value
 */
public JToolBar createToolBar(){
  toolBar=new JToolBar();
  toolBar.putClientProperty("jgoodies.headerStyle","Both");
  toolBar.setRollover(true);
  toolBar.setFloatable(false);
  for (int i=0; i < beans.length; i++) {
    Icon icon;
    JButton button;
    try {
      final JComponent bean=beans[i];
      URL iconURL=bean.getClass().getResource("images/" + bean.getName() + "Color16.gif");
      icon=new ImageIcon(iconURL);
      button=new JButton(icon);
      ActionListener actionListener=new ActionListener(){
        public void actionPerformed(        ActionEvent e){
          installBean(bean);
        }
      }
;
      button.addActionListener(actionListener);
    }
 catch (    Exception e) {
      System.out.println("JCalendarDemo.createToolBar(): " + e);
      button=new JButton(beans[i].getName());
    }
    button.setFocusPainted(false);
    toolBar.add(button);
  }
  return toolBar;
}
 

Example 16

From project ceres, under directory /ceres-ui/src/main/java/com/bc/ceres/swing/demo/.

Source file: FocusApp.java

  21 
vote

@Override public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int row,int column){
  setFont(table.getFont());
  setBackground(Color.WHITE);
  setText(value != null ? value.toString() : "null");
  setBorder(null);
  setIcon(null);
  if (value instanceof javax.swing.plaf.UIResource) {
    if (value instanceof Color) {
      Color color=(Color)value;
      setBackground(color);
      setBorder(new LineBorder(Color.WHITE,2));
    }
 else     if (value instanceof Font) {
      Font font=(Font)value;
      setBackground(Color.WHITE);
      setFont(font);
    }
 else     if (value instanceof Icon) {
      Icon icon=(Icon)value;
    }
 else     if (value instanceof Border) {
      Border border=(Border)value;
    }
  }
  return this;
}
 

Example 17

From project FScape, under directory /src/main/java/de/sciss/fscape/session/.

Source file: DocumentFrame.java

  21 
vote

/** 
 * Recreates the main frame's title bar after a sessions name changed (clear/load/save as session)
 */
public void updateTitle(){
  final File f=doc.getFile();
  final String name=doc.getName();
  final Icon icn;
  writeProtected=false;
  if (f != null) {
    try {
      writeProtected|=!f.canWrite() || ((f.getParentFile() != null) && !f.getParentFile().canWrite());
    }
 catch (    SecurityException e) {
    }
  }
  if (writeProtected) {
    icn=GUIUtil.getNoWriteIcon();
    if (lbWriteProtected.getIcon() != icn) {
      lbWriteProtected.setIcon(icn);
    }
  }
 else   if (lbWriteProtected.getIcon() != null) {
    lbWriteProtected.setIcon(null);
  }
  final String title=procTitle + (doc.isDirty() ? " - \u2022" : " - ") + name;
  setTitle(title);
  actionShowWindow.putValue(Action.NAME,title);
  actionSave.setEnabled(!writeProtected);
  setDirty(doc.isDirty());
  if (writeProtected && !wpHaveWarned && doc.isDirty()) {
    JOptionPane.showMessageDialog(getWindow(),getResourceString("warnWriteProtected"),getResourceString("msgDlgWarn"),JOptionPane.WARNING_MESSAGE,null);
    wpHaveWarned=true;
  }
}
 

Example 18

From project jupload, under directory /src/wjhk/jupload2/gui/.

Source file: SortHeaderRenderer.java

  21 
vote

/** 
 * @see javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,java.lang.Object,boolean,boolean,int,int)
 */
@Override public Component getTableCellRendererComponent(JTable table,Object value,@SuppressWarnings("unused") boolean isSelected,@SuppressWarnings("unused") boolean hasFocus,@SuppressWarnings("unused") int row,int col){
  int index=-1;
  boolean ascending=true;
  if (table instanceof FilePanelJTable) {
    FilePanelJTable sortTable=(FilePanelJTable)table;
    index=sortTable.getSortedColumnIndex();
    ascending=sortTable.isSortedColumnAscending();
  }
  if (table != null) {
    JTableHeader header=table.getTableHeader();
    if (header != null) {
      setForeground(header.getForeground());
      setBackground(header.getBackground());
      setFont(header.getFont());
    }
  }
  Icon icon=ascending ? ASCENDING : DESCENDING;
  setIcon(col == index ? icon : NONSORTED);
  setText((value == null) ? "" : value.toString());
  setBorder(UIManager.getBorder("TableHeader.cellBorder"));
  return this;
}
 

Example 19

From project lilith, under directory /lilith/src/main/java/de/huxhorn/lilith/swing/preferences/.

Source file: AccessStatusTypePanel.java

  21 
vote

public EditConditionAction(){
  super("Edit");
  Icon icon;
{
    URL url=EventWrapperViewPanel.class.getResource("/tango/16x16/actions/list-add.png");
    if (url != null) {
      icon=new ImageIcon(url);
    }
 else {
      icon=null;
    }
  }
  putValue(Action.SMALL_ICON,icon);
  putValue(Action.SHORT_DESCRIPTION,"Edit colors.");
}
 

Example 20

From project medsavant, under directory /medsavant/MedSavantClient/src/org/ut/biolab/medsavant/view/util/.

Source file: TreeBrowserEntry.java

  21 
vote

public Icon getIcon(){
  if (isLeaf) {
    String ext=ClientMiscUtils.getExtension(url);
    try {
      File f=File.createTempFile("savant_icon.","." + ext);
      Icon i=getFileSystemView().getSystemIcon(f);
      f.delete();
      return i;
    }
 catch (    IOException ex) {
      return null;
    }
  }
 else {
    return getFileSystemView().getSystemIcon(DirectorySettings.getMedSavantDirectory());
  }
}
 

Example 21

From project mtc, under directory /mtc-gui/src/main/java/org/drugis/mtc/gui/.

Source file: AuxComponentFactory.java

  21 
vote

public static JPanel createWarningPanel(String warningText){
  Icon icon=UIManager.getIcon("OptionPane.warningIcon");
  if (icon == null) {
    icon=MainWindow.IMAGELOADER.getIcon(FileNames.ICON_WARNING);
  }
  JLabel iconLabel=new JLabel(icon);
  JTextPane textPane=new JTextPane();
  textPane.setText(warningText);
  textPane.setEditable(false);
  textPane.setOpaque(false);
  JPanel panel=new JPanel();
  panel.setLayout(new BoxLayout(panel,BoxLayout.LINE_AXIS));
  panel.setBackground(GUIHelper.COLOR_WARNING);
  panel.add(Box.createRigidArea(new Dimension(8,0)));
  panel.add(iconLabel);
  panel.add(Box.createRigidArea(new Dimension(8,0)));
  panel.add(textPane);
  panel.add(Box.createRigidArea(new Dimension(8,0)));
  return panel;
}
 

Example 22

From project nenya, under directory /core/src/main/java/com/threerings/miso/client/.

Source file: MisoScenePanel.java

  21 
vote

/** 
 * Compute the indicators for any objects in the scene.
 */
public void computeIndicators(){
  Map<SceneObject,SceneObjectIndicator> _unupdated=Maps.newHashMap(_indicators);
  for (int ii=0, nn=_vizobjs.size(); ii < nn; ii++) {
    SceneObject scobj=_vizobjs.get(ii);
    String action=scobj.info.action;
    if (StringUtil.isBlank(action)) {
      continue;
    }
    ObjectActionHandler oah=ObjectActionHandler.lookup(action);
    if (oah != null && !oah.isVisible(action)) {
      continue;
    }
    String tiptext=getTipText(scobj,action);
    if (tiptext != null) {
      Icon icon=getTipIcon(scobj,action);
      SceneObjectIndicator indic=_unupdated.remove(scobj);
      if (indic == null) {
        if (oah != null) {
          indic=oah.createIndicator(this,tiptext,icon);
        }
 else {
          indic=new SceneObjectTip(tiptext,icon);
        }
        _indicators.put(scobj,indic);
      }
 else {
        indic.update(icon,tiptext);
      }
      dirtyIndicator(indic);
    }
  }
  for (  SceneObject toremove : _unupdated.keySet()) {
    SceneObjectIndicator indic=_indicators.remove(toremove);
    indic.removed();
    dirtyIndicator(indic);
  }
  _indicatorsLaidOut=false;
}
 

Example 23

From project packetsamurai, under directory /src/com/l2j/packetsamurai/gui/protocoleditor/.

Source file: TreeTableComboBoxCellEditor.java

  21 
vote

public Component getTableCellEditorComponent(JTable table,Object value,boolean isSelected,int r,int c){
  Component component=super.getTableCellEditorComponent(table,value,isSelected,r,c);
  int offsetRow=r;
  Rectangle bounds=this.table.getCellRect(offsetRow,0,false);
  int offset=bounds.x;
  TreeCellRenderer tcr=this.table.getTreeCellRenderer();
  System.out.println("Renderer is a : " + tcr);
  if (tcr instanceof DelegatingRenderer)   tcr=((DelegatingRenderer)tcr).getDelegateRenderer();
  System.out.println("After un-delegataion, renderer is a : " + tcr);
  if (tcr instanceof DefaultTreeCellRenderer) {
    System.out.println("Renderer is a DefaultTreeCellRenderer");
    Object node=this.table.getPathForRow(offsetRow).getLastPathComponent();
    int depth=this.table.getPathForRow(offsetRow).getPathCount();
    System.out.println("Node's depth is " + depth);
    offset+=(depth - 1) * 20;
    Icon icon;
    if (this.table.getTreeTableModel().isLeaf(node))     icon=((DefaultTreeCellRenderer)tcr).getLeafIcon();
 else     if (this.table.isExpanded(offsetRow))     icon=((DefaultTreeCellRenderer)tcr).getOpenIcon();
 else     icon=((DefaultTreeCellRenderer)tcr).getClosedIcon();
    if (icon != null) {
      offset+=((DefaultTreeCellRenderer)tcr).getIconTextGap() + icon.getIconWidth();
    }
  }
  ((PartTypeComboBox)getComponent()).offset=offset;
  ((PartTypeComboBox)getComponent()).setSelectedItem(value);
  return component;
}
 

Example 24

From project RomRaider, under directory /src/com/romraider/logger/ecu/ui/swing/vertical/.

Source file: VerticalLabelUI.java

  21 
vote

public void paint(Graphics graphics,JComponent component){
  JLabel label=(JLabel)component;
  String text=label.getText();
  Icon icon=(label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();
  if ((icon == null) && (text == null))   return;
  FontMetrics fm=graphics.getFontMetrics();
  PAINT_VIEW_INSETS=component.getInsets(PAINT_VIEW_INSETS);
  PAINT_VIEW_R.x=PAINT_VIEW_INSETS.left;
  PAINT_VIEW_R.y=PAINT_VIEW_INSETS.top;
  PAINT_VIEW_R.height=component.getWidth() - (PAINT_VIEW_INSETS.left + PAINT_VIEW_INSETS.right);
  PAINT_VIEW_R.width=component.getHeight() - (PAINT_VIEW_INSETS.top + PAINT_VIEW_INSETS.bottom);
  PAINT_ICON_R.x=PAINT_ICON_R.y=PAINT_ICON_R.width=PAINT_ICON_R.height=0;
  PAINT_TEXT_R.x=PAINT_TEXT_R.y=PAINT_TEXT_R.width=PAINT_TEXT_R.height=0;
  String clippedText=layoutCL(label,fm,text,icon,PAINT_VIEW_R,PAINT_ICON_R,PAINT_TEXT_R);
  int textWidth=fm.stringWidth(clippedText);
  Graphics2D g2=(Graphics2D)graphics;
  AffineTransform tr=g2.getTransform();
  if (clockwise) {
    g2.rotate(Math.PI / 2);
    g2.translate(component.getHeight() / 2 - textWidth / 2,-component.getWidth());
  }
 else {
    g2.rotate(-Math.PI / 2);
    g2.translate(-component.getHeight() / 2 - textWidth / 2,0);
  }
  if (icon != null)   icon.paintIcon(component,graphics,PAINT_ICON_R.x,PAINT_ICON_R.y);
  if (text != null) {
    int textX=PAINT_TEXT_R.x;
    int textY=PAINT_TEXT_R.y + fm.getAscent();
    if (label.isEnabled())     paintEnabledText(label,graphics,clippedText,textX,textY);
 else     paintDisabledText(label,graphics,clippedText,textX,textY);
  }
  g2.setTransform(tr);
}
 

Example 25

From project ScissLib, under directory /src/main/java/de/sciss/gui/.

Source file: AquaWindowBar.java

  21 
vote

public void paintComponent(Graphics g){
  final Icon icn;
  final ButtonModel m;
  if (isEnabled()) {
    m=getModel();
    if (m.isPressed()) {
      icn=icnPressed;
    }
 else     if (m.isArmed()) {
      icn=icnOver;
    }
 else {
      icn=icnNormal;
    }
  }
 else {
    icn=icnDisabled;
  }
  icn.paintIcon(this,g,0,0);
}
 

Example 26

From project SpoutcraftLauncher, under directory /src/main/java/org/spoutcraft/launcher/skin/components/.

Source file: LoginFrame.java

  21 
vote

private void showJava15Warning(){
  String version=System.getProperty("java.version");
  if (version.startsWith("1.5")) {
    JLabel label=new JLabel();
    Font arial12=new Font("Arial",Font.PLAIN,12);
    label.setFont(arial12);
    StringBuffer style=new StringBuffer("font-family:" + arial12.getFamily() + ";");
    style.append("font-weight:" + (arial12.isBold() ? "bold" : "normal") + ";");
    style.append("font-size:" + arial12.getSize() + "pt;");
    JEditorPane ep=new JEditorPane("text/html","<html><body style=\"" + style + "\">"+ "Spoutcraft requires Java 6 or greater to run, Download"+ "<br>java updates from http://spout.in/javaupdates</body></html>");
    ep.setEditable(false);
    ep.setBackground(label.getBackground());
    final Icon icon=new ImageIcon(Toolkit.getDefaultToolkit().getImage(spoutcraftIcon));
    final String title="Java 1.6 Required!";
    final String[] options={"Ok","Copy URL to clipboard"};
    if (JOptionPane.showOptionDialog(this,ep,title,JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE,icon,options,options[0]) != 0) {
      StringSelection ss=new StringSelection("http://spout.in/javaupdates");
      Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,null);
    }
    dispose();
    System.exit(0);
  }
}
 

Example 27

From project TraVis, under directory /src/travis/resources/.

Source file: IconFactory.java

  21 
vote

public static Icon getClassIcon(StructComponent comp){
  if (comp.isEnum())   return ENUM;
 else   if (comp.isInterface())   return INTERFACE;
  Visibility visibility=comp.getVisibility();
  Icon icon;
switch (visibility) {
case PUBLIC:
    icon=CLASS_PUBLIC;
  break;
case PRIVATE:
icon=CLASS_PRIVATE;
break;
case PROTECTED:
icon=CLASS_PROTECTED;
break;
default :
icon=CLASS_DEFAULT;
break;
}
icon=addModiers(comp,icon);
return icon;
}
 

Example 28

From project uniquery, under directory /src/org/uniquery/gui/query/editor/autocomplete/.

Source file: CompletionMenu.java

  21 
vote

@Override public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus){
  JLabel label=(JLabel)super.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus);
  DatabaseObject o=((MenuItem)model.get(index)).getObject();
  Icon icon;
  if (o == null) {
    icon=icons.get("dot");
  }
 else {
    icon=icons.get(o.getClass().getName());
    if (o instanceof Field) {
      if (((Field)o).isPrimaryKey()) {
        icon=icons.get("PrimaryKey");
      }
    }
  }
  label.setIcon(icon);
  return label;
}
 

Example 29

From project CloudReports, under directory /src/main/java/cloudreports/gui/.

Source file: CloudTree.java

  19 
vote

/** 
 * Creates a new CustomRenderer. 
 */
public CustomRenderer(Icon icon0,Icon icon1,Icon icon2,Icon icon3){
  this.icon0=icon0;
  this.icon1=icon1;
  this.icon2=icon2;
  this.icon3=icon3;
}
 

Example 30

From project codjo-data-process, under directory /codjo-data-process-gui/src/main/java/net/codjo/dataprocess/gui/repository/.

Source file: TreatmentModelGuiActionUtils.java

  19 
vote

TreatmentInputDialog(MutableGuiContext ctxt,String repositoryId,JInternalFrame frame,JList guiTreatmentList,String titre,String message,Icon icon){
  super(frame,titre,message,icon);
  this.ctxt=ctxt;
  this.repositoryId=repositoryId;
  this.frame=frame;
  this.guiTreatmentList=guiTreatmentList;
}
 

Example 31

From project codjo-standalone-common, under directory /src/main/java/net/codjo/gui/.

Source file: LoginWindow.java

  19 
vote

/** 
 * Constructor. Chaque ligne de <code>servers</code> contient une configuration de serveur. Chaque ligne contient : index=0 - label, index=1 - url, index=2 - catalog.
 * @param applicationName Nom de l'application
 * @param servers         Parametres de configuration des serveurs dispo.
 * @param driver          "com.sybase.jdbc2.jdbc.SybDriver"
 * @param jukeBox         Description of Parameter
 * @param icon            Description of Parameter
 */
protected LoginWindow(String applicationName,String[][] servers,String driver,JukeBox jukeBox,Icon icon){
  this.servers=servers;
  this.applicationName=applicationName;
  this.driver=driver;
  this.jukeBox=jukeBox;
  imageLabel.setIcon(icon);
  jbInit();
  for (int i=0; i < servers.length; i++) {
    serverCombo.addItem(servers[i][0]);
  }
  serverCombo.setSelectedIndex(0);
  setNameForGuiTest();
}
 

Example 32

From project extension_libero_manufacturing, under directory /extension/eevolution/libero/src/main/java/it/cnr/imaa/essi/lablib/gui/checkboxtree/.

Source file: QuadristateCheckbox.java

  19 
vote

public QuadristateCheckbox(String text,Icon icon,State state){
  super(text,icon);
  super.addMouseListener(new MouseAdapter(){
    @Override public void mousePressed(    MouseEvent e){
      grabFocus();
      getModel().nextState();
    }
  }
);
  ActionMap map=new ActionMapUIResource();
  map.put("pressed",new AbstractAction(){
    public void actionPerformed(    ActionEvent e){
      grabFocus();
      getModel().nextState();
    }
  }
);
  map.put("released",null);
  SwingUtilities.replaceUIActionMap(this,map);
  setState(state);
}
 

Example 33

From project formic, under directory /src/java/org/formic/wizard/form/.

Source file: GuiForm.java

  19 
vote

/** 
 * Displays a message to the user in the message panel if the message panel is enabled.
 * @param text The text to display.
 * @param icon The icon to display.
 */
public void showMessage(String text,Icon icon){
  if (messagePanel != null) {
    if (text != null && text.trim().length() > 0) {
      messageLabel.setIcon(icon);
      messageArea.setText("<html>" + text + "</html>");
      messageLabel.setVisible(true);
    }
 else {
      messageLabel.setVisible(false);
      messageArea.setText("");
    }
  }
}
 

Example 34

From project glg2d, under directory /src/test/java/glg2d/.

Source file: UIDemo.java

  19 
vote

Icon getIcon(String name){
  try {
    InputStream str=UIDemo.class.getClassLoader().getResourceAsStream(name + ".png");
    return new ImageIcon(ImageIO.read(str));
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
 

Example 35

From project gs-tool, under directory /src/org/graphstream/tool/gui/.

Source file: IconButton.java

  19 
vote

public IconButton(Action action,Icon on,Icon off,Icon click){
  super(off);
  setSize(off.getIconWidth(),off.getIconHeight());
  this.action=action;
  this.onIcon=on;
  this.offIcon=off;
  this.clickIcon=click;
  this.eventId=0;
  this.command=null;
  addMouseListener(this);
}
 

Example 36

From project hudsontrayapp-plugin, under directory /client-common/src/main/java/org/hudson/trayapp/gui/.

Source file: Tray.java

  19 
vote

public static Icon getIconFromHealth(int health){
  if (health == -1) {
    return null;
  }
 else   if (health >= 0) {
    if (health < 20) {
      return Icons.H0019;
    }
 else     if (health < 40) {
      return Icons.H2039;
    }
 else     if (health < 60) {
      return Icons.H4059;
    }
 else     if (health < 80) {
      return Icons.H6079;
    }
 else     if (health <= 100) {
      return Icons.H80PL;
    }
  }
  return null;
}
 

Example 37

From project jreepad, under directory /src/jreepad/.

Source file: JreepadViewer.java

  19 
vote

private final Icon getIcon(String name){
  try {
    URL iconUrl=loader.getResource("images/" + name);
    return new ImageIcon(iconUrl);
  }
 catch (  Exception e) {
    System.err.println("Jreepad: Icon image failed to load: images/" + name);
  }
  return null;
}
 

Example 38

From project JsTestDriver, under directory /idea-plugin/src/com/google/jstestdriver/idea/.

Source file: PluginResources.java

  19 
vote

public Icon getIconForEvent(Event event){
switch (event) {
case CONNECTED:
    return getColorIcon();
case DISCONNECTED:
  return getGreyscaleIcon();
default :
throw new IllegalStateException("Unknown event " + event);
}
}
 

Example 39

From project Maimonides, under directory /src/com/codeko/apps/maimonides/.

Source file: MaimonidesView.java

  19 
vote

public void mostrarPanel(Class clase,String titulo,Icon icono){
  if (Permisos.acceso(clase)) {
    if (!activarPanel(clase,titulo)) {
      try {
        Object ni=clase.newInstance();
        if (ni instanceof IPanel && ni instanceof Component) {
          setPanelActual((IPanel)ni,titulo,icono);
        }
 else {
          throw new Exception("El panel no es IPanel no se puede a?adir.");
        }
      }
 catch (      Exception ex) {
        Logger.getLogger(MaimonidesView.class.getName()).log(Level.SEVERE,null,ex);
      }
    }
  }
 else {
    JOptionPane.showMessageDialog(getFrame(),"No tiene permisos para acceder a ese panel.","Acceso denegado",JOptionPane.WARNING_MESSAGE);
  }
}
 

Example 40

From project niravCS2103, under directory /CS2103/src/gui/.

Source file: Resource.java

  19 
vote

/** 
 * change icon to image
 * @param icon
 * @return image from icon
 */
static Image iconToImage(Icon icon){
  if (icon instanceof ImageIcon) {
    return ((ImageIcon)icon).getImage();
  }
 else {
    int w=icon.getIconWidth();
    int h=icon.getIconHeight();
    GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd=ge.getDefaultScreenDevice();
    GraphicsConfiguration gc=gd.getDefaultConfiguration();
    BufferedImage image=gc.createCompatibleImage(w,h);
    Graphics2D g=image.createGraphics();
    icon.paintIcon(null,g,0,0);
    g.dispose();
    return image;
  }
}
 

Example 41

From project OMS3, under directory /src/main/java/ngmfconsole/.

Source file: VerticalLabelUI.java

  19 
vote

/** 
 * Transposes the view rectangles as appropriate for a vertical view before invoking the super method and copies them after they have been altered by  {@link SwingUtilities#layoutCompoundLabel(FontMetrics,String,Icon,int,int,int,int,Rectangle,Rectangle,Rectangle,int)}
 */
@Override protected String layoutCL(JLabel label,FontMetrics fontMetrics,String text,Icon icon,Rectangle viewR,Rectangle iconR,Rectangle textR){
  verticalViewR=transposeRectangle(viewR,verticalViewR);
  verticalIconR=transposeRectangle(iconR,verticalIconR);
  verticalTextR=transposeRectangle(textR,verticalTextR);
  text=super.layoutCL(label,fontMetrics,text,icon,verticalViewR,verticalIconR,verticalTextR);
  viewR=copyRectangle(verticalViewR,viewR);
  iconR=copyRectangle(verticalIconR,iconR);
  textR=copyRectangle(verticalTextR,textR);
  return text;
}
 

Example 42

From project Openbravo-POS-iPhone-App, under directory /UnicentaPOS/src-beans/com/openbravo/beans/.

Source file: JNumberDialog.java

  19 
vote

public static Double showEditNumber(Component parent,String title,String message,Icon icon){
  Window window=SwingUtilities.windowForComponent(parent);
  JNumberDialog myMsg;
  if (window instanceof Frame) {
    myMsg=new JNumberDialog((Frame)window,true);
  }
 else {
    myMsg=new JNumberDialog((Dialog)window,true);
  }
  myMsg.setTitle(title,message,icon);
  myMsg.setVisible(true);
  return myMsg.m_value;
}
 

Example 43

From project org.ops4j.pax.runner, under directory /pax-runner-idea/ui/src/main/java/org/ops4j/pax/idea/runner/.

Source file: PaxRunnerType.java

  19 
vote

public Icon getIcon(){
  if (m_logger.isDebugEnabled()) {
    m_logger.debug("getIcon()");
  }
  return null;
}
 

Example 44

From project pivote-java, under directory /swing-client/src/main/java/ch/piratenpartei/pivote/ui/.

Source file: PiVoteBanner.java

  19 
vote

private MessageDisplay(Icon icon,String title,String description,Action action,final ResourceBundle.Resource<URL> help){
  super(new BorderLayout());
  JPanel banner=new GradientPanel(new BorderLayout(5,5));
  banner.setBorder(BorderFactory.createEmptyBorder(0,3,0,3));
  banner.setOpaque(false);
  if (icon != null) {
    JLabel iconLabel=new JLabel(icon);
    banner.add(iconLabel,BorderLayout.WEST);
  }
  banner.add(new StyledLabelBuilder().add(title,Font.BOLD).createLabel(),BorderLayout.CENTER);
  if (help != null) {
    JideButton helpButton=new JideButton(res.helpIcon());
    helpButton.setButtonStyle(JideButton.HYPERLINK_STYLE);
    helpButton.setToolTipText(res.whatIsThis());
    helpButton.addActionListener(new ActionListener(){
      @Override public void actionPerformed(      ActionEvent e){
        HelpBrowser.showDialog(MessageDisplay.this,help.get());
      }
    }
);
    banner.add(helpButton,BorderLayout.EAST);
  }
  add(banner,BorderLayout.NORTH);
  if (description != null) {
    MultilineLabel descriptionLabel=new MultilineLabel(description);
    add(descriptionLabel,BorderLayout.CENTER);
  }
  if (action != null) {
    JPanel actionPanel=new JPanel(new FlowLayout(FlowLayout.RIGHT,0,0));
    JideButton actionButton=new JideButton(action);
    actionButton.setButtonStyle(JideButton.HYPERLINK_STYLE);
    actionButton.setForeground(colors().link());
    actionPanel.add(actionButton);
    add(actionPanel,BorderLayout.SOUTH);
  }
}
 

Example 45

From project pos_1, under directory /src-beans/com/openbravo/beans/.

Source file: JNumberDialog.java

  19 
vote

public static Double showEditNumber(Component parent,String title,String message,Icon icon){
  Window window=SwingUtilities.windowForComponent(parent);
  JNumberDialog myMsg;
  if (window instanceof Frame) {
    myMsg=new JNumberDialog((Frame)window,true);
  }
 else {
    myMsg=new JNumberDialog((Dialog)window,true);
  }
  myMsg.setTitle(title,message,icon);
  myMsg.setVisible(true);
  return myMsg.m_value;
}
 

Example 46

From project remoting, under directory /src/main/java/hudson/remoting/jnlp/.

Source file: GUI.java

  19 
vote

public static JPanel wrapInBackgroundImage(JComponent component,Icon backgroundIcon,int verticalAlignment,int horizontalAlignment){
  component.setOpaque(false);
  JPanel backgroundPanel=new JPanel(new GridBagLayout());
  backgroundPanel.add(component,gbc);
  JLabel backgroundImage=new JLabel(backgroundIcon);
  backgroundImage.setPreferredSize(new Dimension(1,1));
  backgroundImage.setMinimumSize(new Dimension(1,1));
  backgroundImage.setVerticalAlignment(verticalAlignment);
  backgroundImage.setHorizontalAlignment(horizontalAlignment);
  backgroundPanel.add(backgroundImage,gbc);
  return backgroundPanel;
}
 

Example 47

From project seamless, under directory /swing/src/main/java/org/seamless/swing/.

Source file: ClosableTabbedPane.java

  19 
vote

/** 
 * Adds a <code>Component</code> represented by a title and an icon.
 * @param title     the title to be displayed in this tab
 * @param component the component to be displayed when this tab is clicked
 * @param extraIcon the icon to be displayed in this tab
 */
public void addTab(String title,Component component,Icon extraIcon){
  boolean doPaintCloseIcon=true;
  try {
    Object prop=null;
    if ((prop=((JComponent)component).getClientProperty("isClosable")) != null) {
      doPaintCloseIcon=(Boolean)prop;
    }
  }
 catch (  Exception ignored) {
  }
  super.addTab(title,doPaintCloseIcon ? new CloseTabIcon(extraIcon) : null,component);
  if (headerViewport == null) {
    for (    Component c : getComponents()) {
      if ("TabbedPane.scrollableViewport".equals(c.getName()))       headerViewport=(JViewport)c;
    }
  }
}
 

Example 48

From project sgl-Editor, under directory /src/de/moonshade/osbe/gui/.

Source file: SGLCellRenderer.java

  19 
vote

/** 
 * Returns an icon.
 * @param resource The icon to retrieve. This should either be a file, or a resource loadable by the current ClassLoader.
 * @return The icon.
 */
private Icon getIcon(String resource){
  ClassLoader cl=getClass().getClassLoader();
  URL url=cl.getResource(resource);
  if (url == null) {
    File file=new File(resource);
    try {
      url=file.toURI().toURL();
    }
 catch (    MalformedURLException mue) {
      mue.printStackTrace();
    }
  }
  return url != null ? new ImageIcon(url) : null;
}
 

Example 49

From project sikuli, under directory /sikuli-ide/src/main/java/org/sikuli/ide/.

Source file: CloseableTabbedPane.java

  19 
vote

/** 
 * Adds a <code>Component</code> represented by a title and an icon.
 * @param title the title to be displayed in this tab
 * @param component the component to be displayed when this tab is clicked
 * @param extraIcon the icon to be displayed in this tab
 */
public void addTab(String title,Component component,Icon extraIcon){
  boolean doPaintCloseIcon=true;
  try {
    Object prop=null;
    if ((prop=((JComponent)component).getClientProperty("isClosable")) != null) {
      doPaintCloseIcon=(Boolean)prop;
    }
  }
 catch (  Exception ignored) {
  }
  super.addTab(title,doPaintCloseIcon ? new CloseTabIcon(extraIcon) : null,component);
  if (headerViewport == null) {
    for (    Component c : getComponents()) {
      if ("TabbedPane.scrollableViewport".equals(c.getName()))       headerViewport=(JViewport)c;
    }
  }
}
 

Example 50

From project SwingOSC, under directory /src/main/java/de/sciss/swingosc/.

Source file: Button.java

  19 
vote

public void setItemIcon(int configureState,Icon icon){
  final StateView sv;
  if (configureState < numStates) {
    sv=(StateView)collStateViews.get(configureState);
    sv.icon=icon;
    if (numColumns == 0)     recalcPrefSize();
    if (configureState == state) {
      stateUpdate();
    }
  }
}
 

Example 51

From project tiled-java, under directory /src/tiled/mapeditor/.

Source file: Resources.java

  19 
vote

/** 
 * Loads the image using  {@link #getImage(String)} and uses it to createa new  {@link ImageIcon} instance.
 * @param filename the filename of the image relative from the<code>resources</code> directory
 * @return the loaded icon, or <code>null</code> when an error occuredwhile loading the image
 */
public static Icon getIcon(String filename){
  try {
    return new ImageIcon(getImage(filename));
  }
 catch (  IOException e) {
    System.out.println("Failed to load as image: " + filename);
  }
catch (  IllegalArgumentException e) {
    System.out.println("Failed to load resource: " + filename);
  }
  return null;
}
 

Example 52

From project Twister, under directory /src/client/userinterface/java/src/.

Source file: CustomDialog.java

  19 
vote

public static String showButtons(Component parent,int messagetype,int optiontype,Icon icon,Object[] options,String title,String message){
  JOptionPane pane=new JOptionPane(message,messagetype,optiontype,icon,options);
  JDialog dialog=pane.createDialog(parent,title);
  dialog.setAlwaysOnTop(true);
  dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  dialog.setVisible(true);
  if (pane.getValue() == null) {
    dialog.dispose();
    return "NULL";
  }
 else {
    dialog.dispose();
    return (String)pane.getValue();
  }
}
 

Example 53

From project UniversalMediaServer, under directory /src/main/java/net/pms/newgui/.

Source file: RestrictedFileSystemView.java

  19 
vote

/** 
 * Icon for a file, directory, or folder as it would be displayed in a system file browser.
 * @param f a <code>File</code> object
 * @return an icon as it would be displayed by a native file chooser, null if not available
 * @see JFileChooser#getIcon
 */
public Icon getSystemIcon(File f){
  if (f != null) {
    return UIManager.getIcon(f.isDirectory() ? "FileView.directoryIcon" : "FileView.fileIcon");
  }
 else {
    return null;
  }
}
 

Example 54

From project utils_1, under directory /src/main/java/net/pterodactylus/util/i18n/gui/.

Source file: I18nAction.java

  19 
vote

/** 
 * Creates a new action that uses the given name as base name to get values from  {@link I18n} and the given icon.
 * @param i18n The i18n handler
 * @param removalReference Removal reference (optional)
 * @param i18nName The base name of the action
 * @param enabled Whether the action should be enabled
 * @param icon The icon for the action
 */
public I18nAction(I18n i18n,RemovalReference removalReference,String i18nName,boolean enabled,Icon icon){
  this.i18n=i18n;
  this.i18nName=i18nName;
  if (icon != null) {
    putValue(Action.SMALL_ICON,icon);
  }
  setEnabled(enabled);
  i18n.addI18nable(this,removalReference);
  updateI18n();
}