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:user.CreateChart.java

private ImageIcon PieChart(DefaultPieDataset dataset, String name) {

    JFreeChart chart = ChartFactory.createPieChart(name, // chart title           
            dataset, // data           
            true, // include legend          
            true, false);/*w  w w .  j  av a 2 s.c om*/

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

From source file:EHRAppointment.ChartPanelDraw.java

/**
 *
 * @param result/*  www .ja va2  s .com*/
 * @param type
 */
public ChartPanelDraw(java.util.List<Vitals> result, String type) {
    this.type = type;
    this.result = result;
    dataset = createTimeDataset();
    chartPanel = createChart(dataset, type);

    JFrame f = new JFrame("Vital Plot"); //Jframe to draw the graph
    f.setTitle("Vital Plot");
    f.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    f.setLayout(new BorderLayout(0, 5));
    f.add(chartPanel, BorderLayout.CENTER);
    f.setIconImage(new ImageIcon(getClass().getResource("/images/icon_transparent.png")).getImage());

    chartPanel.setHorizontalAxisTrace(true); //set properties of the graph 
    chartPanel.setVerticalAxisTrace(true);
    chartPanel.setMouseWheelEnabled(true);

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    panel.add(createTrace()); //Add components to panel
    panel.add(createDate());
    panel.add(createZoom());
    f.add(panel, BorderLayout.SOUTH);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);
}

From source file:bestdeal.gui.Statistique.java

/**
 * Creates new form Statistique//w w  w  .  j  av  a2 s .  c om
 */
@SuppressWarnings("empty-statement")
public Statistique() {
    initComponents();

    btn_retour.setIcon((Icon) new ImageIcon("C:\\Users\\Jedidi\\Desktop\\icone\\retour.png"));
    panel = new ImagePanel(new ImageIcon("C:\\Users\\Jedidi\\Desktop\\111.jpg").getImage());
    Panel.add(panel);
    lbl_log.setIcon((Icon) new ImageIcon("C:\\Users\\Jedidi\\Desktop\\Logo_.png"));

    SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy");
    lbl_date1.setText(sdf1.format(new java.util.Date()));
    SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm:ss");
    lbl_heure.setText(sdf2.format(new java.util.Date()));

    final DefaultPieDataset objDataset = new DefaultPieDataset();
    VoucherDAO v2 = new VoucherDAO();
    String[][] stat = v2.StatDeal();

    objDataset.setValue(stat[0][0], Integer.parseInt(stat[9][0]));
    objDataset.setValue(stat[0][1], Integer.parseInt(stat[9][1]));
    objDataset.setValue(stat[0][2], Integer.parseInt(stat[9][2]));
    objDataset.setValue(stat[0][3], Integer.parseInt(stat[9][3]));
    objDataset.setValue(stat[0][4], Integer.parseInt(stat[9][4]));

    JFreeChart objChart = ChartFactory.createPieChart3D("Best 5 deals", objDataset, true, true, true);
    //String textTitle = "Best 5 deals";
    TextTitle textTitle = objChart.getTitle();
    textTitle.setFont(new Font("Arial", Font.BOLD, 15));

    panel_deals.setLayout(new java.awt.BorderLayout());
    panel_clients.setLayout(new java.awt.BorderLayout());
    panel_vendeurs.setLayout(new java.awt.BorderLayout());
    final ChartPanel CP = new ChartPanel(objChart);
    CP.setPreferredSize(new java.awt.Dimension(600, 500));
    panel_deals.add(CP, BorderLayout.WEST);
    panel_deals.validate();

    TabbedPane.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            if (TabbedPane.getSelectedIndex() == 0) {

                objDataset.clear();
                VoucherDAO v2 = new VoucherDAO();
                String[][] stat = v2.StatDeal();

                objDataset.setValue(stat[0][0], Integer.parseInt(stat[9][0]));
                objDataset.setValue(stat[0][1], Integer.parseInt(stat[9][1]));
                objDataset.setValue(stat[0][2], Integer.parseInt(stat[9][2]));
                objDataset.setValue(stat[0][3], Integer.parseInt(stat[9][3]));
                objDataset.setValue(stat[0][4], Integer.parseInt(stat[9][4]));

                panel_deals.add(CP, BorderLayout.WEST);
                panel_deals.validate();

            } else if (TabbedPane.getSelectedIndex() == 1) {

                objDataset.clear();
                VoucherDAO v2 = new VoucherDAO();
                String[][] stat = v2.StatVendeur();

                objDataset.setValue(stat[1][0], Integer.parseInt(stat[7][0]));
                objDataset.setValue(stat[1][1], Integer.parseInt(stat[7][1]));
                objDataset.setValue(stat[1][2], Integer.parseInt(stat[7][2]));
                objDataset.setValue(stat[1][3], Integer.parseInt(stat[7][3]));
                objDataset.setValue(stat[1][4], Integer.parseInt(stat[7][4]));

                panel_vendeurs.add(CP, BorderLayout.WEST);
                panel_vendeurs.validate();

            } else if (TabbedPane.getSelectedIndex() == 2) {

                objDataset.clear();
                VoucherDAO v2 = new VoucherDAO();
                String[][] stat = v2.StatClient();

                objDataset.setValue(stat[1][0], Integer.parseInt(stat[4][0]));
                objDataset.setValue(stat[1][1], Integer.parseInt(stat[4][1]));
                objDataset.setValue(stat[1][2], Integer.parseInt(stat[4][2]));
                objDataset.setValue(stat[1][3], Integer.parseInt(stat[4][3]));
                objDataset.setValue(stat[1][4], Integer.parseInt(stat[4][4]));

                panel_clients.add(CP, BorderLayout.WEST);
                panel_clients.validate();
            } else if (TabbedPane.getSelectedIndex() == 3) {

            }

        }
    });

}

From source file:de.iew.imageupload.widgets.ContentPane.java

public void registerImageFile(File file) {
    try {/*from  ww  w.  j  a  va 2s .  c  om*/
        ImageIcon imageIcon = new ImageIcon(file.getAbsolutePath());
        JLabel imageLabel = new JLabel(imageIcon, JLabel.CENTER);
        imageLabel.setPreferredSize(new Dimension(100, 100));
        imageLabel.setSize(new Dimension(100, 100));
        imageLabel.addMouseListener(this.imageMouseClickHandler);
        imageLabel.setBackground(Color.WHITE);
        imageLabel.setBorder(new EmptyBorder(10, 10, 10, 10));
        imageLabel.putClientProperty("Image File", file);

        this.imageGridPane.add(imageLabel);
        this.imageGridPane.revalidate();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:RasterImageTest.java

public RasterImageFrame() {
    setTitle("RasterImageTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    BufferedImage image = makeMandelbrot(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    add(new JLabel(new ImageIcon(image)));
}

From source file:com.cmsoftware.keyron.vista.Login.java

/**
 * Constructor de la clase Login./*  w w  w .  ja  v a  2 s .com*/
 */
public Login() {
    initComponents();
    setLocationRelativeTo(null);
    setIconImage(
            new ImageIcon(getClass().getResource("/com/cmsoftware/keyron/recursos/iconoBarra.png")).getImage());
}

From source file:logica_controladores.controlador_estadistica.java

public static void grafica_orden(JPanel panel_grafica_orden, Inventario inventario, JLabel lbLinea) {
    XYSeries serie = null;// w ww . java  2 s  .c  o  m
    XYSeries serie_2 = null;

    JFreeChart linea;

    serie = new XYSeries("graficas relacion gastos-orden");
    Gasto gasto_minimo = valor_minimo(inventario);
    Gasto gasto_max = valor_maximo(inventario);
    for (int i = 0; i < inventario.getGastos().size(); i = i + inventario.getReorden_max()) {
        serie.add(inventario.getGastos().get(i).getOrden_inicial(), inventario.getGastos().get(i).getGastos());
    }
    serie_2 = new XYSeries("graficas relacion gastos-reorden");

    for (int i = 0; i < inventario.getGastos().size(); i = i + inventario.getOrden_max()) {
        serie_2.add(inventario.getGastos().get(i).getReorden(), inventario.getGastos().get(i).getGastos());
    }
    final XYSeriesCollection datos = new XYSeriesCollection();
    datos.addSeries(serie);
    datos.addSeries(serie_2);

    linea = ChartFactory.createXYLineChart(
            "grafica representativa de ordenes por corrida, gasto_minimo(orden: "
                    + gasto_minimo.getOrden_inicial() + "reorden: " + gasto_minimo.getReorden() + ")= "
                    + gasto_minimo.getGastos(),
            "rango", "gastos", datos, PlotOrientation.VERTICAL, true, true, true);
    final XYPlot plot = (XYPlot) linea.getPlot();
    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    configurarDomainAxis(domainAxis, inventario);
    configurarRangeAxis(rangeAxis, gasto_minimo.getGastos(), gasto_max.getGastos());
    BufferedImage graficoLinea = linea.createBufferedImage(600, 280);
    lbLinea.setSize(panel_grafica_orden.getSize());
    lbLinea.setIcon(new ImageIcon(graficoLinea));
    panel_grafica_orden.updateUI();
}

From source file:com.igormaznitsa.nbmindmap.utils.Icons.java

private Icons(final String name) {
    final InputStream in = Icons.class.getClassLoader()
            .getResourceAsStream("com/igormaznitsa/nbmindmap/icons/" + name); //NOI18N
    try {//w  w w .ja va 2s.com
        this.icon = 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.biosis.biosislite.vistas.inventario.MantenimientoFactura.java

public MantenimientoFactura() {
    initComponents();//from w  w  w. ja  va 2  s.  c o  m
    listar();

    ImageIcon fot = new ImageIcon("img/no_disponible.png");
    Icon icono = new ImageIcon(fot.getImage().getScaledInstance(lblFactura.getWidth(), lblFactura.getHeight(),
            Image.SCALE_DEFAULT));
    lblFactura.setIcon(icono);

    FormularioUtil.activarComponente(panelDatos, false);
    FormularioUtil.activarComponente(panelOpciones, true);
    FormularioUtil.activarComponente(panelGuardar, false);
}

From source file:brainflow.core.ImageBrowser.java

private void initSourceView() {
    sourceView = new JList();
    final DefaultListModel model = new DefaultListModel();
    for (IImageSource source : sourceList.sourceList) {
        model.addElement(source);/*from w  ww.j a  va 2 s. c  om*/
    }

    sourceView.setModel(model);
    sourceView.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    ButtonPanel panel = new ButtonPanel(SwingConstants.CENTER);

    JButton nextButton = new JButton("Next");
    ImageIcon icon = new ImageIcon(getClass().getClassLoader().getResource("icons/control_play_blue.png"));
    nextButton.setIcon(icon);

    JButton prevButton = new JButton("Previous");
    icon = new ImageIcon(getClass().getClassLoader().getResource("icons/control_rev_blue.png"));
    prevButton.setIcon(icon);
    panel.addButton(prevButton);
    panel.addButton(nextButton);
    panel.setSizeConstraint(ButtonPanel.SAME_SIZE);

    JPanel container = new JPanel(new BorderLayout());
    container.setBorder(new TitledBorder("Image List"));
    container.add(new JScrollPane(sourceView), BorderLayout.CENTER);
    container.add(panel, BorderLayout.SOUTH);
    add(container, BorderLayout.WEST);

    nextButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int index = sourceView.getSelectedIndex();
            if (index == (sourceList.size() - 1)) {
                index = 0;
            } else {
                index++;
            }

            updateView(index);

        }
    });

    sourceView.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = sourceView.getSelectedIndex();
            if (currentModel.getSelectedLayer().getDataSource() != sourceView.getSelectedValue()) {
                System.out.println("updating view");
                updateView(index);
            } else {
                System.out.println("not updating view ");
            }

        }
    });
}