Example usage for javax.swing JLabel setIcon

List of usage examples for javax.swing JLabel setIcon

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The icon this component will display.")
public void setIcon(Icon icon) 

Source Link

Document

Defines the icon this component will display.

Usage

From source file:eu.europa.ec.markt.dss.applet.util.ComponentFactory.java

/**
 * //ww  w . ja  v a 2 s  .c o m
 * @param text
 * @param icon
 * @return
 */
public static JLabel createLabel(final String text, final Icon icon) {
    final JLabel label = new JLabel(text);
    label.setIcon(icon);
    return label;
}

From source file:logica_controladores.controlador_estadistica.java

public static void grafica_reorden(JPanel panel_grafica_orden, Inventario inventario, JLabel lbLinea) {
    XYSeries serie_2 = null;// w w w  .java  2 s  .  c  o m
    XYDataset datos;
    JFreeChart linea;

    serie_2 = new XYSeries("graficas relacion gastos-reorden");

    for (int i = 0; i < inventario.getGastos().size(); i++) {
        serie_2.add(inventario.getGastos().get(i).getReorden(), inventario.getGastos().get(i).getGastos());
    }
    datos = new XYSeriesCollection(serie_2);
    linea = ChartFactory.createXYLineChart("grafica representativa de reordenes por corrida", "punto de orden",
            "gastos", datos, PlotOrientation.VERTICAL, true, true, true);
    BufferedImage graficoLinea = linea.createBufferedImage(panel_grafica_orden.getWidth(),
            panel_grafica_orden.getHeight());
    lbLinea.setSize(panel_grafica_orden.getSize());
    lbLinea.setIcon(new ImageIcon(graficoLinea));
    panel_grafica_orden.updateUI();
}

From source file:Main.java

public Main() throws HeadlessException {
    setSize(300, 300);/* www  .ja v  a2  s.  c  om*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new FlowLayout(FlowLayout.LEFT));

    Icon icon = new ImageIcon("a.png");
    JLabel label1 = new JLabel("Full Name :", icon, JLabel.LEFT);

    JLabel label2 = new JLabel("Address :", JLabel.LEFT);
    label2.setIcon(new ImageIcon("b.png"));

    getContentPane().add(label1);
    getContentPane().add(label2);
}

From source file:CustomTreeCellRenderer.java

public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
        boolean leaf, int row, boolean hasFocus) {

    super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

    JLabel label = (JLabel) this;

    label.setIcon(rendererIcon);

    return this;
}

From source file:Main.java

public Main() {
    setLayout(new GridLayout(ROWS, COLS));
    for (int row = 0; row < grid.length; row++) {
        for (int col = 0; col < grid[row].length; col++) {
            JLabel label = new JLabel();
            int index = random.nextInt(COLORS.length);
            label.setIcon(ICONS[index]);
            add(label);/*w  w w.ja  v a2 s . c  om*/
            grid[row][col] = label;
        }
    }
    new Timer(TIMER_DELAY, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            for (int i = 0; i < NUMBER_TO_SWAP; i++) {
                int row = random.nextInt(ROWS);
                int col = random.nextInt(COLS);
                int iconIndex = random.nextInt(ICONS.length);
                grid[row][col].setIcon(ICONS[iconIndex]);
            }
        }
    }).start();
}

From source file:de.tor.tribes.ui.renderer.TendencyTableCellRenderer.java

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    JLabel label = (JLabel) c;
    Integer val = (Integer) value;
    String text = "";
    if (val == 0) {
        label.setIcon(yellow);
    } else if (val > 0) {
        label.setIcon(red);//from   w  w  w .  j  av  a  2s  .  c om
        text = "(+ " + val + ")";
    } else if (val < 0) {
        label.setIcon(green);
        text = "(" + val + ")";
    }
    label.setText(StringUtils.center(text, 9));
    return label;
}

From source file:EditableColorColumn.java

private void configureRenderer(JLabel renderer, Object value) {
    if ((value != null) && (value instanceof Color)) {
        renderer.setIcon(new DiamondIcon((Color) value));
        renderer.setText("");
    } else {/*from   w  w  w.  j av  a  2 s. c o  m*/
        renderer.setIcon(null);
        renderer.setText((String) value);
    }
}

From source file:Interface.ResultadoJanela.java

public ResultadoJanela(List<Resultado> tar, List<Resultado> jac, List<Resultado> och, List<Resultado> sbi) {
    //  super("Resultado");
    CategoryDataset dataset;//from ww  w .  j a  va 2 s.  c om

    //---------------------gerando resultados tarantula-------------------------------------
    dataset = gerarDataset(tar, jac, och, sbi);
    JFreeChart chart = gerarGrafico(dataset);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setDomainZoomable(true);

    JLabel lAjuda = new JLabel("Ajuda", JLabel.RIGHT);
    lAjuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icone_informacao.gif"))); // NOI18N
    lAjuda.setPreferredSize(new Dimension(50, 50));
    lAjuda.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            lAjudaMouseClicked(evt);
        }
    });

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(lAjuda, BorderLayout.BEFORE_FIRST_LINE);
    panel.add(chartPanel, BorderLayout.LINE_START);
    JLabel lTabela = new JLabel("Tabela de Resultados", JLabel.CENTER);
    panel.add(lTabela, BorderLayout.SOUTH);

    JTable table = new JTable(criarValores(tar, jac, och, sbi), criarColunas());

    // Adiciona o JTable dentro do painel
    JScrollPane scrollPane = new JScrollPane(table);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    panel.add(scrollPane, BorderLayout.SOUTH);

    JFrame frame = new JFrame();
    frame.setTitle("JLoc - Resultado");
    frame.setVisible(true);
    frame.add(panel);

    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

private JPanel getPanel() {
    JPanel panel = new JPanel();
    JLabel label = new JLabel("Java Technology Dive Log");
    ImageIcon image = null;//from   w  w  w  .j  ava 2 s .  c  om
    try {
        image = new ImageIcon(ImageIO.read(new URL("http://www.java2s.com/style/download.png")));
    } catch (Exception mue) {
        mue.printStackTrace();
    }
    label.setIcon(image);

    JButton button = new JButton("EXIT");
    button.addActionListener(e -> dialog.dispose());

    panel.add(label);
    panel.add(button);

    return panel;
}

From source file:generadorqr.jifrNuevoQr.java

public static void Mostrar_Visualizador(JLabel Pantalla, String RutaDestino) {
    try {/*from   www  .  j a v  a  2s  . co  m*/
        Image capturarImgSoloLectura = ImageIO.read(new File(RutaDestino));
        Image obtenerImagen = capturarImgSoloLectura.getScaledInstance(Pantalla.getPreferredSize().width,
                Pantalla.getPreferredSize().height, Image.SCALE_SMOOTH);
        Icon iconoEscalado = new ImageIcon(obtenerImagen);
        Pantalla.setIcon(iconoEscalado);
    } catch (java.io.IOException e) {
        e.printStackTrace();
    }
}