Example usage for javax.swing JButton getName

List of usage examples for javax.swing JButton getName

Introduction

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

Prototype

public String getName() 

Source Link

Document

Gets the name of the component.

Usage

From source file:DateChooserPanel.java

/**
 * Handles action-events from the date panel.
 *
 * @param e information about the event that occurred.
 */// w w  w .  j av  a2 s  . com
public void actionPerformed(final ActionEvent e) {

    if (e.getActionCommand().equals("monthSelectionChanged")) {
        final JComboBox c = (JComboBox) e.getSource();

        // In most cases, changing the month will not change the selected
        // day.  But if the selected day is 29, 30 or 31 and the newly
        // selected month doesn't have that many days, we revert to the 
        // last day of the newly selected month...
        int dayOfMonth = this.chosenDate.get(Calendar.DAY_OF_MONTH);
        this.chosenDate.set(Calendar.DAY_OF_MONTH, 1);
        this.chosenDate.set(Calendar.MONTH, c.getSelectedIndex());
        int maxDayOfMonth = this.chosenDate.getActualMaximum(Calendar.DAY_OF_MONTH);
        this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, maxDayOfMonth));
        refreshButtons();
    } else if (e.getActionCommand().equals("yearSelectionChanged")) {
        if (!this.refreshing) {
            final JComboBox c = (JComboBox) e.getSource();
            final Integer y = (Integer) c.getSelectedItem();

            // in most cases, changing the year will not change the 
            // selected day.  But if the selected day is Feb 29, and the
            // newly selected year is not a leap year, we revert to 
            // Feb 28...
            int dayOfMonth = this.chosenDate.get(Calendar.DAY_OF_MONTH);
            this.chosenDate.set(Calendar.DAY_OF_MONTH, 1);
            this.chosenDate.set(Calendar.YEAR, y.intValue());
            int maxDayOfMonth = this.chosenDate.getActualMaximum(Calendar.DAY_OF_MONTH);
            this.chosenDate.set(Calendar.DAY_OF_MONTH, Math.min(dayOfMonth, maxDayOfMonth));
            refreshYearSelector();
            refreshButtons();
        }
    } else if (e.getActionCommand().equals("todayButtonClicked")) {
        setDate(new Date());
    } else if (e.getActionCommand().equals("dateButtonClicked")) {
        final JButton b = (JButton) e.getSource();
        final int i = Integer.parseInt(b.getName());
        final Calendar cal = getFirstVisibleDate();
        cal.add(Calendar.DATE, i);
        setDate(cal.getTime());
    }
}

From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java

@Override
public void actionPerformed(ActionEvent e) {
    JButton btn = (JButton) e.getSource();
    if (btn.getName().equals(ResourceBundleHelper.getMessageString("videoTab.enter"))) {
        doEnter();//from   w  w  w.  jav a 2  s .  c  o  m
    } else if (btn.getName().equals(ResourceBundleHelper.getMessageString("videoTab.load"))) {
        doLoad();
    } else if (btn.getName().equals(ResourceBundleHelper.getMessageString("videoTab.close"))) {
        doClose();
    } else if (btn.getName().equals(ResourceBundleHelper.getMessageString("videoTab.save"))) { // Saving after testing the regex by clicking on enter
        saveConfig();
    }
}

From source file:kolacer.Kolacer.java

private void jBut_barva_grad_ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBut_barva_grad_ActionPerformed
    JButton sauc = (JButton) evt.getSource();
    short gradID = -1;
    int saucHash = sauc.hashCode();

    if (saucHash == jBut_barva_grad_A.hashCode()) {
        gradID = 0;/*from w  w w.  j a va 2s.c om*/
    } else if (saucHash == jBut_barva_grad_B.hashCode()) {
        gradID = 1;
    } else {
        System.err.println("Invailt gradient color change from: " + sauc.getName());
        return;
    }

    Color bar = ziskejBarvu(false);
    if (bar == null)
        return;
    switch (gradID) {
    case 0:
        jBut_barva_grad_A.setBackground(barvaGradA = bar);
        break;
    case 1:
        jBut_barva_grad_B.setBackground(barvaGradB = bar);
        break;
    }

}

From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java

protected JPanel createButtonsPanel(Action[] actions, final DialogWindow dialog) {
    JPanel buttonsPanel = new JPanel();

    boolean hasPrimaryAction = false;
    for (final Action action : actions) {
        JButton button = new JButton(action.getCaption());
        String icon = action.getIcon();

        if (icon != null) {
            button.setIcon(AppBeans.get(IconResolver.class).getIconResource(icon));
        }/*from  ww  w.ja  v a 2  s  .  co m*/

        final DialogActionHandler dialogActionHandler = new DialogActionHandler(dialog, action);
        button.addActionListener(dialogActionHandler);
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JButton b = (JButton) e.getSource();
                userActionsLog.trace("Button (name = {}, text = {}) was clicked in dialog", b.getName(),
                        b.getText());
            }
        });
        if (actions.length == 1) {
            dialog.addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosing(WindowEvent e) {
                    dialogActionHandler.onClose();
                }
            });
        }

        button.setPreferredSize(
                new Dimension(button.getPreferredSize().width, DesktopComponentsHelper.BUTTON_HEIGHT));
        button.setMaximumSize(new Dimension(Integer.MAX_VALUE, DesktopComponentsHelper.BUTTON_HEIGHT));

        if (action instanceof AbstractAction && ((AbstractAction) action).isPrimary()) {
            hasPrimaryAction = true;

            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    button.requestFocus();
                }
            });
        }

        buttonsPanel.add(button);
    }

    if (!hasPrimaryAction && actions.length > 0) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                buttonsPanel.getComponent(0).requestFocus();
            }
        });
    }

    return buttonsPanel;
}

From source file:Form.Principal.java

public void PanelUsuarios() {
    int i = 0;//w w w .  java 2  s .c o  m
    int Altura = 0;
    Color gris = new Color(44, 44, 44);
    Color azul = new Color(0, 153, 255);
    Color rojo = new Color(221, 76, 76);
    try {
        //Consultamos todos los clientes
        ResultSet Comandos = Funcion.Select(st, "SELECT * FROM usuarios where Tipo!='Administrador';");
        //Ciclo para crear un panel para cada uno
        while (Comandos.next()) {
            //Creamos un panel con alineacion a la izquierda
            JPanel Panel = new JPanel();
            Panel.setLayout(null);
            jPanel12.add(Panel);
            //Tamao del panel
            Panel.setSize(500, 200);
            // La posicion y del panel ira incrementando para que no se encimen
            Altura = 40 + (i * 220);
            Panel.setLocation(175, Altura);
            Panel.setBackground(Color.white);
            Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
            //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel
            //se pase a la siguiente linea y para el margen izquierdo
            JLabel Foto = new JLabel();
            Foto.setSize(150, 150);
            File FotoPerfil = new File("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".png");
            File FotoPerfil2 = new File("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".jpg");
            if (FotoPerfil.exists()) {
                ImageIcon Imagen = new ImageIcon("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".png");
                Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(),
                        Image.SCALE_SMOOTH);
                Icon IconoEscalado = new ImageIcon(ImagenEscalada);
                Foto.setIcon(IconoEscalado);
            } else if (FotoPerfil2.exists()) {
                ImageIcon Imagen = new ImageIcon("Imagenes/Fotos Perfil/" + Comandos.getInt("id") + ".jpg");
                Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(),
                        Image.SCALE_SMOOTH);
                Icon IconoEscalado = new ImageIcon(ImagenEscalada);
                Foto.setIcon(IconoEscalado);
            } else {
                ImageIcon Imagen = new ImageIcon(getClass().getResource("/Imagen/Default.png"));
                Image ImagenEscalada = Imagen.getImage().getScaledInstance(Foto.getWidth(), Foto.getHeight(),
                        Image.SCALE_SMOOTH);
                Icon IconoEscalado = new ImageIcon(ImagenEscalada);
                Foto.setIcon(IconoEscalado);
            }
            JLabel Nombre = new JLabel();
            Nombre.setText("Nombre de Usuario: " + Comandos.getString("Nombre"));
            JLabel Contrasena = new JLabel();
            Contrasena.setText(("Contrasea: " + Comandos.getString("contrasena")));
            JButton Editar = new JButton();
            Editar.setText("Editar");
            Editar.setName(Comandos.getString("id"));
            Editar.setBackground(azul);
            JButton Eliminar = new JButton();
            Eliminar.setText("Eliminar");
            Eliminar.setName(Comandos.getString("id"));
            Eliminar.setBackground(rojo);
            MouseListener mlEditar = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    presionadoactual = 24;
                    Color azul = new Color(0, 182, 230);
                    jButton24.setBackground(azul);
                    JButton source = (JButton) e.getSource();
                    System.out.println(source.getName());
                    jPanel17.setVisible(false);
                    jButton30.setLocation(470, 480);
                    jButton31.setLocation(270, 480);
                    jLabel2.setToolTipText(null);
                    jTabbedPane2.setSelectedIndex(5);
                    editando = true;
                    PerfilUsuario(Integer.parseInt(source.getName()));
                    Color gris = new Color(44, 44, 44);
                    jButton4.setBackground(gris);
                }
            };
            MouseListener mlEliminar = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    JButton source = (JButton) e.getSource();
                    System.out.println(source.getName());
                    Funcion.Update(st, "DELETE FROM usuarios WHERE id = " + source.getName() + ";");
                    jPanel12.removeAll();
                    PanelUsuarios();
                    jPanel12.repaint();
                }
            };
            Editar.addMouseListener(mlEditar);
            Eliminar.addMouseListener(mlEliminar);
            //Fuente del texto;
            Nombre.setFont(new Font("Verdana", Font.PLAIN, 15));
            Nombre.setForeground(gris);
            Contrasena.setFont(new Font("Verdana", Font.PLAIN, 15));
            Contrasena.setForeground(gris);
            Editar.setFont(new Font("Verdana", Font.PLAIN, 15));
            Editar.setForeground(Color.white);
            Eliminar.setFont(new Font("Verdana", Font.PLAIN, 15));
            Eliminar.setForeground(Color.white);
            //Aadimos los label al panel correspondiente del cliente
            Panel.add(Foto);
            Panel.add(Nombre);
            Panel.add(Contrasena);
            Panel.add(Editar);
            Panel.add(Eliminar);
            Foto.setLocation(10, 20);
            Nombre.setLocation(170, 30);
            Nombre.setSize(300, 45);
            Contrasena.setLocation(170, 60);
            Contrasena.setSize(300, 45);
            Editar.setLocation(170, 100);
            Editar.setSize(120, 40);
            Eliminar.setLocation(315, 100);
            Eliminar.setSize(120, 40);
            i++;
        }
    } catch (SQLException ex) {
        Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
    }
    //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi
    jPanel12.setPreferredSize(new Dimension(jPanel12.getWidth(), Altura + 150));

}

From source file:Form.Principal.java

public void PanelClientes() {
    int i = 0;//ww w.j a  v a2  s .c o  m
    int Altura = 0;
    Color gris = new Color(44, 44, 44);
    Color rojo = new Color(221, 76, 76);
    Color azul = new Color(0, 153, 255);
    try {
        //Consultamos todos los clientes
        ResultSet Comandos = Funcion.Select(st, "SELECT * FROM cliente;");
        //Ciclo para crear un panel para cada uno
        while (Comandos.next()) {
            //Creamos un panel con alineacion a la izquierda
            JPanel Panel = new JPanel();
            Panel.setLayout(null);
            jPanel8.add(Panel);
            //Tamao del panel
            Panel.setSize(700, 195);
            // La posicion y del panel ira incrementando para que no se encimen
            Altura = 30 + (i * 205);
            Panel.setLocation(50, Altura);
            Panel.setBackground(Color.white);
            Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
            //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel
            //se pase a la siguiente linea y para el margen izquierdo
            JLabel RFC = new JLabel();
            RFC.setText("RFC: " + Comandos.getString("RFC"));
            JLabel Nombre = new JLabel();
            Nombre.setText("Nombre: " + Comandos.getString("NombreCliente"));
            JTextArea Direccion = new JTextArea();
            Direccion.setLineWrap(true);
            Direccion.setBorder(null);
            Direccion.setText("Direccin: " + Comandos.getString("Direccion"));
            JLabel Correo = new JLabel();
            Correo.setText("Correo: " + Comandos.getString("correo"));
            JButton VerMas = new JButton();
            VerMas.setText("Ver ms");
            VerMas.setName(Comandos.getString("idCliente"));
            VerMas.setBackground(azul);
            JButton Eliminar = new JButton();
            Eliminar.setText("Eliminar");
            Eliminar.setName(Comandos.getString("idCliente"));
            Eliminar.setBackground(rojo);
            MouseListener mlVerMas = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                    e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    JButton source = (JButton) e.getSource();
                    id = Integer.parseInt(source.getName());
                    jTabbedPane2.setSelectedIndex(4);
                    jButton16.setVisible(true);
                    jButton17.setVisible(true);
                    jButtonEditar.setVisible(true);
                    jPanel9.setVisible(true);
                    jPanel10.setVisible(true);
                    jPanel14.setVisible(false);
                    LlenarPanel();
                }
            };
            VerMas.addMouseListener(mlVerMas);
            MouseListener mlEliminar = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                    e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    JButton source = (JButton) e.getSource();
                    Funcion.Update(st, "DELETE FROM cliente WHERE idCliente = " + source.getName() + ";");
                    Autocompletar.removeAllItems();
                    Autocompletar = new TextAutoCompleter(jTextField2);
                    ResultSet Comandos = Funcion.Select(st, "SELECT * FROM cliente;");
                    try {
                        while (Comandos.next()) {
                            Autocompletar.addItem(Comandos.getString("RFC"));
                        }
                    } catch (SQLException ex) {
                        //Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    jPanel8.removeAll();
                    PanelClientes();
                    jPanel8.repaint();
                }
            };
            Eliminar.addMouseListener(mlEliminar);
            //Fuente del texto
            RFC.setFont(new Font("Verdana", Font.PLAIN, 14));
            RFC.setForeground(gris);
            Nombre.setFont(new Font("Verdana", Font.PLAIN, 14));
            Nombre.setForeground(gris);
            Direccion.setFont(new Font("Verdana", Font.PLAIN, 14));
            Direccion.setForeground(gris);
            Correo.setFont(new Font("Verdana", Font.PLAIN, 14));
            Correo.setForeground(gris);
            VerMas.setFont(new Font("Verdana", Font.PLAIN, 14));
            VerMas.setForeground(Color.white);
            Eliminar.setFont(new Font("Verdana", Font.PLAIN, 14));
            Eliminar.setForeground(Color.white);
            /*VERMAS.setFont(new Font("Verdana", Font.PLAIN, 13));
            VERMAS.setForeground(azul);*/
            //Aadimos los label al panel correspondiente del cliente
            Panel.add(RFC);
            Panel.add(Nombre);
            Panel.add(Direccion);
            Panel.add(Correo);
            Panel.add(VerMas);
            Panel.add(Eliminar);
            RFC.setLocation(30, 10);
            RFC.setSize(610, 30);
            Nombre.setLocation(30, 40);
            Nombre.setSize(610, 30);
            Direccion.setLocation(30, 75);
            Direccion.setSize(610, 40);
            Correo.setLocation(30, 115);
            Correo.setSize(610, 30);
            VerMas.setLocation(210, 150);
            VerMas.setSize(120, 35);
            Eliminar.setLocation(390, 150);
            Eliminar.setSize(120, 35);
            //Panel.add(VERMAS);
            i++;
        }
    } catch (SQLException ex) {
        Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
    }
    //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi
    jPanel8.setPreferredSize(new Dimension(jPanel8.getWidth(), Altura + 205));
}

From source file:Form.Principal.java

public void PanelFacturas() {
    int i = 0;//from w  w w  . j av  a2 s .  c  o  m
    int Altura = 0;
    Color gris = new Color(44, 44, 44);
    Color azul = new Color(0, 153, 255);
    Color rojo = new Color(221, 76, 76);
    try {
        //Consultamos todos los clientes
        ResultSet Comandos = Funcion.Select(st,
                "SELECT factura_emitida.*, cliente.*  FROM cliente,factura_emitida  WHERE factura_emitida.idCliente = cliente.idCliente;");
        //Ciclo para crear un panel para cada uno
        while (Comandos.next()) {
            Variables.Comentario = Comandos.getString("Observaciones");
            //Creamos un panel con alineacion a la izquierda
            JPanel Panel = new JPanel();
            Panel.setLayout(null);
            jPanel11.add(Panel);
            //Tamao del panel
            Panel.setSize(680, 200);
            // La posicion y del panel ira incrementando para que no se encimen
            Altura = 30 + (i * 250);
            Panel.setLocation(50, Altura);
            Panel.setBackground(Color.white);
            Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
            //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel
            //se pase a la siguiente linea y para el margen izquierdo

            JLabel FolioFactura = new JLabel();
            FolioFactura.setText("Folio de factura: " + Comandos.getString("idFacturaEmitida"));
            JLabel RFC = new JLabel();
            RFC.setText("RFC: " + Comandos.getString("RFC"));
            JLabel Nombre = new JLabel();
            Nombre.setText("Nombre: " + Comandos.getString("NombreCliente"));
            JLabel Direccion = new JLabel();
            Direccion.setText("Direccion: " + Comandos.getString("Direccion"));
            JLabel Correo = new JLabel();
            Correo.setText("Correo: " + Comandos.getString("correo"));
            JLabel Fecha = new JLabel();
            Fecha.setText("Fecha y Hora de emisin: " + Comandos.getString("FechaEmision"));

            JButton Abre = new JButton();
            Abre.setText("Abrir");
            Abre.setName(Comandos.getString("idFacturaEmitida"));
            Abre.setBackground(azul);
            JButton Cancelar = new JButton();
            Cancelar.setText("Cancelar");
            Cancelar.setName(Comandos.getString("idFacturaEmitida"));
            Cancelar.setBackground(rojo);
            MouseListener mlAbre = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    try {
                        JButton source = (JButton) e.getSource();
                        idFacClien = Integer.parseInt(source.getName());
                        ResultSet Comandos = Funcion.Select(st,
                                "SELECT *FROM factura_emitida  WHERE idfacturaEmitida=" + idFacClien + ";");
                        while (Comandos.next()) {
                            Variables.FechaFactura = Comandos.getString("FechaEmision");
                            Variables.FechaSistema = Comandos.getString("fechasistema");
                            Variables.idFactura = Comandos.getInt("idFacturaEmitida");
                        }
                        Consulta();
                        Variables.guardar = false;
                        NuevoPdf pdf = new NuevoPdf("Factura.pdf");
                        pdf.main();
                        File myfile = new File("Factura.pdf");
                        Desktop.getDesktop().open(myfile);
                        Comandos = Funcion.Select(st, "SELECT * FROM factura_emitida;");
                        try {
                            if (Comandos.next()) {
                                Comandos.last();
                                Variables.idFactura = Comandos.getInt("idFacturaEmitida") + 1;
                            } else {
                                Variables.idFactura = 1;
                            }
                        } catch (SQLException ex) {
                            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    } catch (Exception ex) {
                        Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            };
            MouseListener mlCancelar = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    JButton source = (JButton) e.getSource();
                    Variables.Cancelar = Integer.parseInt(source.getName());
                    String Comando = "UPDATE factura_emitida SET Observaciones='Factura Cancelada' WHERE idFacturaEmitida="
                            + Variables.Cancelar + ";";
                    Funcion.Update(st, Comando);
                    jPanel11.removeAll();
                    PanelFacturas();
                    jPanel11.repaint();
                }
            };
            Abre.addMouseListener(mlAbre);
            Cancelar.addMouseListener(mlCancelar);
            //Fuente del texto;
            FolioFactura.setFont(new Font("Verdana", Font.PLAIN, 13));
            FolioFactura.setForeground(gris);
            RFC.setFont(new Font("Verdana", Font.PLAIN, 13));
            RFC.setForeground(gris);
            Nombre.setFont(new Font("Verdana", Font.PLAIN, 13));
            Nombre.setForeground(gris);
            Direccion.setFont(new Font("Verdana", Font.PLAIN, 13));
            Direccion.setForeground(gris);
            Correo.setFont(new Font("Verdana", Font.PLAIN, 13));
            Correo.setForeground(gris);
            Fecha.setFont(new Font("Verdana", Font.PLAIN, 13));
            Fecha.setForeground(gris);
            /// Botones
            Abre.setFont(new Font("Verdana", Font.PLAIN, 15));
            Abre.setForeground(Color.white);
            Cancelar.setFont(new Font("Verdana", Font.PLAIN, 15));
            Cancelar.setForeground(Color.white);
            //Aadimos los label al panel correspondiente del cliente
            Panel.add(FolioFactura);
            Panel.add(RFC);
            Panel.add(Nombre);
            Panel.add(Direccion);
            Panel.add(Correo);
            Panel.add(Fecha);
            Panel.add(Abre);

            FolioFactura.setLocation(15, 5);
            FolioFactura.setSize(400, 45);

            RFC.setLocation(15, 25);
            RFC.setSize(400, 45);

            Nombre.setLocation(15, 45);
            Nombre.setSize(500, 45);

            Direccion.setLocation(15, 65);
            Direccion.setSize(650, 45);

            Correo.setLocation(15, 85);
            Correo.setSize(500, 45);

            Fecha.setLocation(15, 105);
            Fecha.setSize(500, 45);
            /// Botones Tamao y localizacion
            if (Variables.Tipo.equalsIgnoreCase("Administrador")) { // Verificamos que sea un Administrador
                Panel.add(Cancelar);
                Abre.setLocation(185, 160);
                Abre.setSize(120, 30);
                Cancelar.setLocation(350, 160);
                Cancelar.setSize(120, 30);

                if (Variables.Comentario.equalsIgnoreCase("Factura Cancelada")) {
                    Cancelar.setVisible(false);
                    Abre.setLocation(290, 160);
                    Abre.setSize(120, 30);
                }

            } else {
                Abre.setLocation(290, 160);
                Abre.setSize(120, 30);
            }

            i++;
        }
    } catch (SQLException ex) {
        Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
    }
    //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi
    jPanel11.setPreferredSize(new Dimension(jPanel11.getWidth(), Altura + 300));

}

From source file:org.apache.jmeter.visualizers.StatGraphVisualizer.java

@Override
public void actionPerformed(ActionEvent event) {
    boolean forceReloadData = false;
    final Object eventSource = event.getSource();
    if (eventSource == displayButton) {
        actionMakeGraph();// w w w  .j a  v a2  s . c om
    } else if (eventSource == saveGraph) {
        saveGraphToFile = true;
        try {
            ActionRouter.getInstance().getAction(ActionNames.SAVE_GRAPHICS, SaveGraphics.class.getName())
                    .doAction(new ActionEvent(this, event.getID(), ActionNames.SAVE_GRAPHICS));
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    } else if (eventSource == saveTable) {
        JFileChooser chooser = FileDialoger.promptToSaveFile("statistics.csv"); //$NON-NLS-1$
        if (chooser == null) {
            return;
        }
        FileWriter writer = null;
        try {
            writer = new FileWriter(chooser.getSelectedFile()); // TODO Charset ?
            CSVSaveService.saveCSVStats(getAllTableData(model, FORMATS), writer,
                    saveHeaders.isSelected() ? getLabels(COLUMNS) : null);
        } catch (IOException e) {
            JMeterUtils.reportErrorToUser(e.getMessage(), "Error saving data");
        } finally {
            JOrphanUtils.closeQuietly(writer);
        }
    } else if (eventSource == chooseForeColor) {
        Color color = JColorChooser.showDialog(null, JMeterUtils.getResString("aggregate_graph_choose_color"), //$NON-NLS-1$
                colorBarGraph);
        if (color != null) {
            colorForeGraph = color;
        }
    } else if (eventSource == syncWithName) {
        graphTitle.setText(namePanel.getName());
    } else if (eventSource == dynamicGraphSize) {
        // if use dynamic graph size is checked, we disable the dimension fields
        if (dynamicGraphSize.isSelected()) {
            graphWidth.setEnabled(false);
            graphHeight.setEnabled(false);
        } else {
            graphWidth.setEnabled(true);
            graphHeight.setEnabled(true);
        }
    } else if (eventSource == columnSelection) {
        if (columnSelection.isSelected()) {
            columnMatchLabel.setEnabled(true);
            applyFilterBtn.setEnabled(true);
            caseChkBox.setEnabled(true);
            regexpChkBox.setEnabled(true);
        } else {
            columnMatchLabel.setEnabled(false);
            applyFilterBtn.setEnabled(false);
            caseChkBox.setEnabled(false);
            regexpChkBox.setEnabled(false);
            // Force reload data
            forceReloadData = true;
        }
    }
    // Not 'else if' because forceReloadData 
    if (eventSource == applyFilterBtn || forceReloadData) {
        if (columnSelection.isSelected() && columnMatchLabel.getText() != null
                && columnMatchLabel.getText().length() > 0) {
            pattern = createPattern(columnMatchLabel.getText());
        } else if (forceReloadData) {
            pattern = null;
            matcher = null;
        }
        if (getFile() != null && getFile().length() > 0) {
            clearData();
            FilePanel filePanel = (FilePanel) getFilePanel();
            filePanel.actionPerformed(event);
        }
    } else if (eventSource instanceof JButton) {
        // Changing color for column
        JButton btn = ((JButton) eventSource);
        if (btn.getName() != null) {
            try {
                BarGraph bar = eltList.get(Integer.parseInt(btn.getName()));
                Color color = JColorChooser.showDialog(null, bar.getLabel(), bar.getBackColor());
                if (color != null) {
                    bar.setBackColor(color);
                    btn.setBackground(bar.getBackColor());
                }
            } catch (NumberFormatException nfe) {
            } // nothing to do
        }
    }
}

From source file:org.rockyroadshub.planner.core.gui.calendar.FormPane.java

private void onTrigger(JButton button) {
    String name = button.getName();

    switch (name) {
    case Globals.SAVE:
        onSave();/*from  w  w  w.ja va 2s.co  m*/
        break;
    default:
        DisplayPane.getInstance().refresh();
        CalendarPane.getInstance().refresh();
        MainPane.getInstance().showPane(name);
        clear();
        break;
    }
}

From source file:org.rockyroadshub.planner.core.gui.calendar.ViewPane.java

private void onTrigger(JButton button) {
    String name = button.getName();
    switch (name) {
    case Globals.SAVE:
        onSave();//ww w  .ja v a 2s  . c  om
        break;
    case Globals.EDIT:
        onEdit();
        break;
    default:
        DisplayPane.getInstance().refresh();
        CalendarPane.getInstance().refresh();
        MainPane.getInstance().showPane(name);
        clear();
        break;
    }
}