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:ds.monte.carlo.Application.java

public Application() {
    initComponents();//from   w  w w. j a va2 s.  c  o  m
    initProgressBar();
    this.setTitle("Monte Carlo");
    ImageIcon img = new ImageIcon("img.png");
    this.setIconImage(img.getImage());
    numberOfReplications = 1000;
    initSeed = 0;
    jLabel3.setVisible(false);
}

From source file:com.silkroad.ui.renderer.node.BuddyNode.java

/**
 * ???//from w w  w  .  j a va  2 s  . com
 *
 * @return
 */
public UIPanel getView() {
    if (avatar == null || !avatar.equals(buddy.getAvatar())) {
        avatar = buddy.getAvatar();
        ImageIcon icon = new ImageIcon(avatar);
        avatarImage.setIcon(icon);
    }
    if (!StringUtils.equals(nickLbl.getText(), buddy.getNick())) {
        nickLbl.setText(buddy.getNick());
    }
    if (!StringUtils.equals(signLbl.getText(), buddy.getSign())) {
        signLbl.setText(buddy.getSign());
    }
    return view;
}

From source file:com.pos.spatobiz.app.view.desktop.GambarAbstract.java

/** This method is called from within the constructor to
 * initialize the form.//w  w  w .ja  va 2  s  .  co m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    labelAbstract = new JLabel();

    setLayout(new BorderLayout());

    labelAbstract.setHorizontalAlignment(SwingConstants.CENTER);
    labelAbstract.setIcon(
            new ImageIcon(getClass().getResource("/com/pos/spatobiz/app/resource/image/abstract.png"))); // NOI18N
    add(labelAbstract, BorderLayout.CENTER);
}

From source file:view.statistics.RequestStatsAndPrediction.java

/**
 * Creates new form PredictRequests/*from  w  w w .  j a va 2  s. com*/
 */
public RequestStatsAndPrediction() throws FileNotFoundException, IOException {
    initComponents();
    FileInputStream imgStream = null;
    File imgfile = new File("..\\BBMS\\src\\images\\drop.png");
    imgStream = new FileInputStream(imgfile);
    BufferedImage bi = ImageIO.read(imgStream);
    ImageIcon myImg = new ImageIcon(bi);
    this.setFrameIcon(myImg);
    setTitle("Request Statistics and Prediction");
    sdcontroller = new SampleDetailsController();
    Calendar calendar = Calendar.getInstance();
    yearChooser.setStartYear(calendar.get(Calendar.YEAR));
    monthChooser.setMonth(calendar.get(calendar.MONTH) + 1);

    int year = yearChooser.getYear();
    int month = monthChooser.getMonth() + 1;

    int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    int currentMonth = Calendar.getInstance().get(Calendar.MONTH) + 1;

    int data[][] = null;

    try {
        data = sdcontroller.getYearlyRequestCountsOf(month);
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(RequestStatsAndPrediction.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SQLException ex) {
        Logger.getLogger(RequestStatsAndPrediction.class.getName()).log(Level.SEVERE, null, ex);
    }

    if (year >= currentYear && month >= currentMonth) {

        try {
            predictText.setText(Predictions.getPredictedRequestsOf(year, month) + "");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(RequestStatsAndPrediction.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(RequestStatsAndPrediction.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        JOptionPane.showMessageDialog(this,
                "Predictions available only for future months. Only the graph will be drawn", "Error",
                JOptionPane.ERROR_MESSAGE);
        predictText.setText("Invalid input!");
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    if (data != null) {
        for (int i = 0; i < data[0].length; i++) {
            dataset.setValue(data[1][i], "Bla bla bla", data[0][i] + "");
        }
    }

    JFreeChart chart = ChartFactory.createLineChart3D(
            "Yearly Blood Request Count For The Month of " + getMontName(month + ""), "Year", "Request Count",
            dataset, PlotOrientation.VERTICAL, false, true, false);
    chart.setBackgroundPaint(Color.PINK);
    chart.getTitle().setPaint(Color.RED);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLUE);

    ChartPanel panel = new ChartPanel(chart);
    panel.setPreferredSize(new java.awt.Dimension(200, 350));
    chartAreaPanel.setLayout(new GridLayout());
    chartAreaPanel.removeAll();
    chartAreaPanel.revalidate();
    chartAreaPanel.add(panel);
    chartAreaPanel.repaint();

    this.repaint();

}

From source file:Ventanas.VentanaVerGrafico.java

private void initGUI() {
    try {//  ww w .jav  a 2  s.c o m
        this.setLayout(null);
        this.setIconImage(
                new ImageIcon(getClass().getClassLoader().getResource("Ventanas/is_a4af.gif")).getImage());
        this.setTitle("Grfica");
        this.setSize(705, 580);
        this.getContentPane().setBackground(new java.awt.Color(204, 230, 230));
        this.setLocationRelativeTo(null);
        this.setResizable(false);

        {
            CategoryDataset dataset = createCategoryDataset(((Vector) VentanaVerEstadisticas.datosEstadistica));
            JFreeChart chart = ChartFactory.createBarChart3D("Rendimiento de los operarios", "Operarios", "",
                    dataset, PlotOrientation.HORIZONTAL, true, true, false);
            chart.setBackgroundPaint(new Color(204, 230, 230));
            grafica = chart.createBufferedImage(700, 500);
            paint(grafica.getGraphics());
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.KgmlEdMain.java

/**
 * Constructs a new instance of the editor.
 *//*from w  w w.jav  a  2  s .c o  m*/
public KgmlEdMain(final boolean showMainFrame, String applicationName, String[] args) {
    // URL config,
    final ThreadSafeOptions tso = new ThreadSafeOptions();
    SplashScreenInterface splashScreen = new DBEsplashScreen(applicationName, "", new Runnable() {
        public void run() {
            if (showMainFrame) {
                ClassLoader cl = this.getClass().getClassLoader();
                String path = this.getClass().getPackage().getName().replace('.', '/');
                ImageIcon icon = new ImageIcon(cl.getResource(path + "/ipklogo16x16_5.png"));
                final MainFrame mainFrame = MainFrame.getInstance();
                mainFrame.setIconImage(icon.getImage());

                Thread t = new Thread(new Runnable() {
                    public void run() {
                        long waitTime = 0;
                        long start = System.currentTimeMillis();
                        do {
                            if (ErrorMsg.getAppLoadingStatus() == ApplicationStatus.ADDONS_LOADED)
                                break;
                            try {
                                Thread.sleep(50);
                            } catch (InterruptedException e) {
                            }
                            waitTime = System.currentTimeMillis() - start;
                        } while (waitTime < 2000);
                        SplashScreenInterface ss = (SplashScreenInterface) tso.getParam(0, null);
                        ss.setVisible(false);
                        mainFrame.setVisible(true);
                    }
                }, "wait for add-on initialization");
                t.start();
            }

        }
    });
    tso.setParam(0, splashScreen);

    ClassLoader cl = this.getClass().getClassLoader();
    String path = this.getClass().getPackage().getName().replace('.', '/');
    ImageIcon icon = new ImageIcon(cl.getResource(path + "/ipklogo16x16_5.png"));
    ((DBEsplashScreen) splashScreen).setIconImage(icon.getImage());

    splashScreen.setVisible(true);
    GravistoMainHelper.createApplicationSettingsFolder(splashScreen);
    if (!(new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_accepted")).exists()
            && !(new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_rejected")).exists()) {

        ReleaseInfo.setIsFirstRun(true);

        splashScreen.setVisible(false);
        splashScreen.setText("Request KEGG License Status");
        JOptionPane.showMessageDialog(null, "<html><h3>KEGG License Status Evaluation</h3>" + "While "
                + DBEgravistoHelper.DBE_GRAVISTO_VERSION
                + " is available as a academic research tool at no cost to commercial and non-commercial users, for using<br>"
                + "KEGG related functions, it is necessary for all users to adhere to the KEGG license.<br>"
                + "For using " + DBEgravistoHelper.DBE_GRAVISTO_VERSION
                + " you need also be aware of information about licenses and conditions for<br>"
                + "usage, listed at the program info dialog and the " + DBEgravistoHelper.DBE_GRAVISTO_VERSION
                + " website (" + ReleaseInfo.getAppWebURL() + ").<br><br>"
                + DBEgravistoHelper.DBE_GRAVISTO_VERSION
                + " does not distribute information from KEGG but contains functionality for the online-access to  information from KEGG wesite.<br><br>"
                + "<b>Before these functions are available to you, you should  carefully read the following license information<br>"
                + "and decide if it is legit for you to use the KEGG related program functions. If you choose not to use the KEGG functions<br>"
                + "all other features of this application are still available and fully working.",
                DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization",
                JOptionPane.INFORMATION_MESSAGE);

        JOptionPane.showMessageDialog(null,
                "<html><h3>KEGG License Status Evaluation</h3>" + MenuItemInfoDialog.getKEGGlibText(),
                DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization",
                JOptionPane.INFORMATION_MESSAGE);

        int result = JOptionPane.showConfirmDialog(null, "<html><h3>Enable KEGG functions?",
                DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization",
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (result == JOptionPane.YES_OPTION) {
            try {
                new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_accepted").createNewFile();
            } catch (IOException e) {
                ErrorMsg.addErrorMessage(e);
            }
        }
        if (result == JOptionPane.NO_OPTION) {
            try {
                new File(ReleaseInfo.getAppFolderWithFinalSep() + "license_kegg_rejected").createNewFile();
            } catch (IOException e) {
                ErrorMsg.addErrorMessage(e);
            }
        }
        if (result == JOptionPane.CANCEL_OPTION) {
            JOptionPane.showMessageDialog(null, "Startup aborted.",
                    DBEgravistoHelper.DBE_GRAVISTO_VERSION + " Program Features Initialization",
                    JOptionPane.INFORMATION_MESSAGE);
            System.exit(0);
        }
        splashScreen.setVisible(true);
    }

    GravistoMainHelper.initApplicationExt(args, splashScreen, cl, null, null);

}

From source file:net.sf.maltcms.chromaui.charts.GradientPaintScale.java

/**
 *
 * @param args/*from   w ww .ja v  a2  s .c  o  m*/
 */
public static void main(String[] args) {
    double[] st = ImageTools.createSampleTable(256);
    Logger.getLogger(GradientPaintScale.class.getName()).info(Arrays.toString(st));
    double min = 564.648;
    double max = 24334.234;
    GradientPaintScale gps = new GradientPaintScale(st, min, max,
            new Color[] { Color.BLACK, Color.RED, Color.orange, Color.yellow, Color.white });
    double val = min;
    double incr = (max - min) / (st.length - 1);
    Logger.getLogger(GradientPaintScale.class.getName()).log(Level.INFO, "Increment: {0}", incr);
    for (int i = 0; i < st.length; i++) {
        Logger.getLogger(GradientPaintScale.class.getName()).log(Level.INFO, "Value: {0}", val);
        gps.getPaint(val);
        val += incr;
    }
    Logger.getLogger(GradientPaintScale.class.getName()).info("Printing min and max values");
    Logger.getLogger(GradientPaintScale.class.getName()).log(Level.INFO, "Min: {0} gps min: {1}",
            new Object[] { min, gps.getPaint(min) });
    Logger.getLogger(GradientPaintScale.class.getName()).log(Level.INFO, "Max: {0} gps max: {1}",
            new Object[] { max, gps.getPaint(max) });
    JList jl = new JList();
    DefaultListModel dlm = new DefaultListModel();
    jl.setModel(dlm);
    jl.setCellRenderer(new ListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            if (value instanceof JLabel) {
                // Border b =
                // BorderFactory.createCompoundBorder(BorderFactory
                // .createEmptyBorder(0, 0, 5, 0), BorderFactory
                // .createLineBorder(Color.BLACK, 1));
                // ((JLabel) value).setBorder(b);
                return (Component) value;
            }
            return new JLabel(value.toString());
        }
    });
    JFrame jf = new JFrame();
    jf.add(new JScrollPane(jl));
    jf.setVisible(true);
    jf.setSize(200, 400);
    for (int alpha = -10; alpha <= 10; alpha++) {
        for (int beta = 1; beta <= 20; beta++) {
            gps.setAlphaBeta(alpha, beta);
            // System.out.println(Arrays.toString(gps.st));
            // System.out.println(Arrays.toString(gps.sampleTable));
            BufferedImage bi = gps.getLookupImage();
            ImageIcon ii = new ImageIcon(bi);
            dlm.addElement(new JLabel(ii));
        }
    }

}

From source file:SystemColorChooserPanel.java

public Icon getSmallDisplayIcon() {
    return new ImageIcon("yourFile.gif");
}

From source file:SampleDesktop.java

protected void loadBackgroundImage() {
    ImageIcon icon = new ImageIcon("images/matterhorn.gif");
    JLabel l = new JLabel(icon);
    l.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight());

    // Place the image in the lowest possible layer so nothing
    // can ever be painted under it.
    desk.add(l, new Integer(Integer.MIN_VALUE));
}

From source file:user.CreateChart.java

private ImageIcon XYChart(XYSeriesCollection dataset, String name, String X, String Y) {

    JFreeChart chart = ChartFactory.createXYLineChart(name, X, Y, dataset, PlotOrientation.VERTICAL, true, true,
            false);/* ww w. j  av  a 2  s.  c  o m*/

    ImageIcon ii = new ImageIcon(chart.createBufferedImage(592, 500));
    return ii;
}