Example usage for javax.swing ImageIcon ImageIcon

List of usage examples for javax.swing ImageIcon ImageIcon

Introduction

In this page you can find the example usage for javax.swing ImageIcon ImageIcon.

Prototype

public ImageIcon(byte[] imageData) 

Source Link

Document

Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF, JPEG, or (as of 1.3) PNG.

Usage

From source file:de.kletterfreak98.xmass.ui.WeightChart.java

public WeightChart(String title, TimeSeries values) {
    super(title);

    setIconImage(//from ww  w .  j  a  va2s .  co m
            new ImageIcon(getClass().getClassLoader().getResource("de/kletterfreak98/xmass/resources/fav.png"))
                    .getImage());

    final String chartTitle = strings.getString("weightcourse");
    final XYDataset dataset = new TimeSeriesCollection(values);

    final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, strings.getString("date"),
            strings.getString("weightinkg"), dataset, false, true, false);

    final XYPlot plot = chart.getXYPlot();
    plot.setDataset(1, new TimeSeriesCollection(values));
    plot.mapDatasetToRangeAxis(1, 1);
    final XYItemRenderer renderer = plot.getRenderer();
    renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    if (renderer instanceof StandardXYItemRenderer) {
        final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
        rr.setShapesFilled(true);
    }

    final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, Color.black);
    renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    plot.setRenderer(1, renderer2);

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    SimpleDateFormat sdf;
    if (Main.settings.getLang().equals(Locale.GERMANY)) {
        sdf = new SimpleDateFormat("dd.MM.yyyy");
        axis.setDateFormatOverride(sdf);
    } else {
        sdf = new SimpleDateFormat("MM/dd/yyyy");
        axis.setDateFormatOverride(sdf);
    }

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    JPanel panel = new JPanel();
    JButton close = new JButton(strings.getString("close"));
    close.setPreferredSize(new Dimension(close.getWidth(), 30));
    close.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    panel.setLayout(new BorderLayout());
    panel.add(chartPanel, BorderLayout.CENTER);
    panel.add(close, BorderLayout.SOUTH);
    panel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(panel);
    setUndecorated(true);
}

From source file:Main.java

protected void makeActionsPretty() {
    Action a;// ww  w  . ja  v a  2  s .  c  o m
    a = textComp.getActionMap().get(DefaultEditorKit.cutAction);
    a.putValue(Action.SMALL_ICON, new ImageIcon("cut.gif"));
    a.putValue(Action.NAME, "Cut");

    a = textComp.getActionMap().get(DefaultEditorKit.copyAction);
    a.putValue(Action.SMALL_ICON, new ImageIcon("copy.gif"));
    a.putValue(Action.NAME, "Copy");

    a = textComp.getActionMap().get(DefaultEditorKit.pasteAction);
    a.putValue(Action.SMALL_ICON, new ImageIcon("paste.gif"));
    a.putValue(Action.NAME, "Paste");

    a = textComp.getActionMap().get(DefaultEditorKit.selectAllAction);
    a.putValue(Action.NAME, "Select All");
}

From source file:com.mirth.connect.client.ui.SettingsPanelMap.java

public SettingsPanelMap(String tabName) {
    super(tabName);

    initComponents();/* w w w . j a va  2s .c om*/

    addTask(TaskConstants.SETTINGS_CONFIGURATION_MAP_IMPORT, "Import Map",
            "Import a properties file into the configuration map. This will remove and replace any existing map values.",
            "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/report_disk.png")));
    addTask(TaskConstants.SETTINGS_CONFIGURATION_MAP_EXPORT, "Export Map",
            "Export the configuration map to a properties file.", "",
            new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/report_go.png")));

    setVisibleTasks(2, 3, true);
}

From source file:com.igormaznitsa.mindmap.swing.services.DefaultImageIconService.java

@Nonnull
private static Icon loadIcon(@Nonnull final String name) {
    final InputStream in = ScalableIcon.class.getClassLoader()
            .getResourceAsStream("com/igormaznitsa/mindmap/swing/panel/icons/" + name); //NOI18N
    try {// w ww.  ja  va  2s  .c o m
        return new ImageIcon(ImageIO.read(in));
    } catch (IOException ex) {
        throw new Error("Can't load icon " + name, ex); //NOI18N
    } finally {
        IOUtils.closeQuietly(in);
    }
}

From source file:com.mirth.connect.client.ui.SettingsPanelDatabaseTasks.java

public SettingsPanelDatabaseTasks(String tabName) {
    super(tabName);
    setLayout(new MigLayout("insets 12, novisualpadding, hidemode 3, fill"));
    setBackground(UIConstants.BACKGROUND_COLOR);
    initComponents();//w w  w  .  j  a  v a 2s.c om
    addTask(TaskConstants.SETTINGS_RUN_DATABASE_TASK, "Run Task", "Execute the selected database task.", "",
            new ImageIcon(Frame.class.getResource("images/control_play_blue.png")));
    addTask(TaskConstants.SETTINGS_CANCEL_DATABASE_TASK, "Cancel Task", "Cancel the selected database task.",
            "", new ImageIcon(Frame.class.getResource("images/stop.png")));
    setVisibleTasks(2, 3, false);
}

From source file:it.unibas.spicygui.controllo.tree.ActionShowHideConstraints.java

public ActionShowHideConstraints() {
    this.executeInjection();
    this.putValue(NAME, NbBundle.getMessage(Costanti.class, Costanti.ACTION_SHOW_HIDE_CONSTRAINTS));
    this.putValue(SMALL_ICON, new ImageIcon(ImageUtilities.loadImage(Costanti.ICONA_SHOW_HIDE_CONSTRAINTS)));
    this.putValue(Action.MNEMONIC_KEY, new Integer(java.awt.event.KeyEvent.VK_H));
    this.setEnabled(false);
    registraAzione();/*from  w  ww. jav a2 s .  c  om*/
}

From source file:net.landora.video.infopanel.VideoInfoPanel.java

@Override
public void loadContext(MultiValueMap context) {
    Collection col = context.getCollection(VideoMetadata.class);

    VideoMetadata md = (VideoMetadata) UIUtils.select(col);

    byte[] data = md.getPosterImage();
    if (data == null) {
        lblPicture.setIcon(null);//w  ww .  jav a2  s .  com
    } else {
        try {
            Image img = ImageIO.read(new ByteArrayInputStream(data));
            lblPicture.setIcon(new ImageIcon(img));
        } catch (IOException ex) {
            lblPicture.setIcon(null);
            LoggerFactory.getLogger(getClass()).warn("Error loading image.", ex);
        }
    }

    Map<String, String> values = md.getAllInformation(false);

    StringBuilder buffer = new StringBuilder();
    buffer.append("<html>");

    Font font = lblPicture.getFont();
    buffer.append("<head>");
    buffer.append("<style type=\"text/css\">");

    buffer.append(" { margin-top: 0px; margin-bottom: 0px; margin-right: 0px; margin-left: 0px;  }");

    buffer.append("table { border-collapse:collapse; }");

    buffer.append(" td { ");
    buffer.append(" font-family: \"");
    buffer.append(font.getFamily());
    buffer.append("\"; font-size: ");
    buffer.append(font.getSize() - 2);
    buffer.append("px; ");

    buffer.append(" }\n");

    buffer.append(" td.label { ");
    buffer.append("text-align: right; ");
    buffer.append("font-weight:bold; ");
    buffer.append("white-space:nowrap; ");

    buffer.append(" font-family: \"");
    buffer.append(font.getFamily());
    buffer.append("\"; font-size: ");
    buffer.append(font.getSize() - 2);
    buffer.append("px; ");

    buffer.append("} ");
    buffer.append("</style>");
    buffer.append("</head>");
    buffer.append("<body>");
    buffer.append("<table>");
    boolean first = true;
    for (Map.Entry<String, String> entry : values.entrySet()) {
        buffer.append("<tr><td class=\"label\">");
        buffer.append(StringEscapeUtils.escapeHtml(entry.getKey()));
        buffer.append("</td><td>");
        buffer.append(StringEscapeUtils.escapeHtml(entry.getValue()));
        buffer.append("</td></tr>");
    }

    buffer.append("</table>");
    buffer.append("</body>");
    buffer.append("</html>");

    txtInfo.setContentType("text/html");
    txtInfo.setText(buffer.toString());
}

From source file:iqq.app.core.service.impl.ResourceServiceImpl.java

/**
 * ??/* w  w w.j  ava2 s .  co  m*/
 *
 * @param filename
 * @return
 */
@Override
public ImageIcon getUserIcon(String filename) {
    return new ImageIcon(getUserFile(filename).getAbsolutePath());
}

From source file:Starry.java

public void init() {
    Image starry = new ImageIcon("yourFile.gif").getImage();
    StarPanel starPanel = new StarPanel(starry);
    getContentPane().add(starPanel, BorderLayout.CENTER);
}

From source file:ufmotionsuite.SpiralGraph.java

public void Graph() {
    XYSeries series = new XYSeries("X vs Y");
    for (int i = 0; i < arrLength; i++) {
        //System.out.println("Run");
        series.add(theta[i], r[i]);//from  w  w  w. java 2 s . c om
    }
    XYDataset dataset = new XYSeriesCollection(series);
    JFreeChart chart = ChartFactory.createXYLineChart("Distance from Origin over Angle", "Theta",
            "R (Distance)", dataset, org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false);
    BufferedImage image = chart.createBufferedImage(600, 600);
    jLabel1.setIcon(new ImageIcon(image));
    this.setSize(800, 800);
}