Example usage for javax.swing JButton setSize

List of usage examples for javax.swing JButton setSize

Introduction

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

Prototype

public void setSize(int width, int height) 

Source Link

Document

Resizes this component so that it has width width and height height .

Usage

From source file:Main.java

public static void main(String... args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel contentPane = new JPanel();
    contentPane.setOpaque(true);/*  w w w .j  av a 2s. c  o  m*/
    contentPane.setBackground(Color.WHITE);
    contentPane.setLayout(null);

    JLabel label = new JLabel("This JPanel uses Absolute Positioning", JLabel.CENTER);
    label.setSize(300, 30);
    label.setLocation(5, 5);

    JButton button = new JButton("USELESS");
    button.setSize(100, 30);
    button.setLocation(95, 45);

    contentPane.add(label);
    contentPane.add(button);

    frame.setContentPane(contentPane);
    frame.setSize(310, 125);
    frame.setLocationByPlatform(true);
    frame.setVisible(true);
}

From source file:neironweb.Frame.java

public Frame() {
    super("neural network");
    //JPanel pane = new JPanel();

    setLayout(null);//from   w  ww. j a v  a2s  .  c  o m

    JPanel mailPanel = new JPanel();
    mailPanel.setLayout(null);
    mailPanel.setLocation(50, 30);
    mailPanel.setSize(300, 170);
    mailPanel.setBorder(BorderFactory.createLineBorder(Color.black));

    JLabel mailLabel = new JLabel("e-mail:");
    mailLabel.setLocation(10, 10);
    mailLabel.setSize(50, 30);
    mailPanel.add(mailLabel);

    JLabel dirMailLabel = new JLabel("direct:");
    dirMailLabel.setLocation(10, 50);
    dirMailLabel.setSize(50, 30);
    mailPanel.add(dirMailLabel);

    JTextField mailField = new JTextField("mail@mail.ru");
    mailField.setSize(150, 30);
    mailField.setLocation(80, 10);
    mailPanel.add(mailField);

    JTextField textField = new JTextField("INBOX");
    textField.setLocation(80, 50);
    textField.setSize(150, 30);
    mailPanel.add(textField);

    JButton mailButton = new JButton("Analyze");
    mailButton.setLocation(80, 90);
    mailButton.setSize(150, 30);
    mailPanel.add(mailButton);

    //        JButton eduButton = new JButton("Start education");
    //        eduButton.setLocation(0, 50);
    //        eduButton.setSize(150, 30);
    //        buttonPanel.add(eduButton);

    XYSeries xyser = new XYSeries("");
    XYDataset xy = new XYSeriesCollection(xyser);
    JFreeChart jf = ChartFactory.createXYLineChart("Education", "X", "Y", xy);

    for (int i = 0; i < 100; i++)
        xyser.add(i, Math.cos(i));

    ChartPanel chartPanel = new ChartPanel(jf);
    chartPanel.setSize(700, 300);
    chartPanel.setLocation(50, 230);
    chartPanel.setBorder(BorderFactory.createLineBorder(Color.black));

    //        JPanel myChartPanel = new JPanel();        
    //        myChartPanel.setLayout(null);
    //        myChartPanel.setLocation(50, 230);
    //        myChartPanel.setSize(700, 300);
    //        myChartPanel
    //      myChartPanel.add(chartPanel);        

    setSize(800, 600);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container con = this.getContentPane(); // inherit main frame
    //con.add(pane); 
    con.add(mailPanel);
    //con.add(myChartPanel);
    con.add(chartPanel);
    setVisible(true);

}

From source file:herramientas.Ecualizacion_histograma.java

private void controles() {
    final JFrame v = new JFrame();
    v.setSize(220, 120);/*w  w w .  j  ava2 s . c  o  m*/
    v.setVisible(true);
    v.setTitle("Controles");
    v.setResizable(false);

    JPanel panel = new JPanel();
    v.add(panel);

    JButton Hist = new JButton("Histograma");
    Hist.setSize(220, 30);
    panel.add(Hist);
    JButton Hist_ac = new JButton("Histograma Acumulativo");
    panel.add(Hist_ac);
    JButton Hist_ec = new JButton("Histograma Ecualizado");
    panel.add(Hist_ec);

    Hist.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            v.dispose();
            histograma();
        }
    });

    Hist_ac.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            v.dispose();
            histogramaAcumulativo();
        }
    });

    Hist_ec.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //                ecualizacion();
            v.dispose();
            gestor_img.anadirImagen(ecualizacion());
        }
    });

}

From source file:jcine.CineForm.java

private void buildHall(Asiento[] asientos) {
    //Encontraremos las dimensiones de sala
    Integer maxX = 0;/*from ww w.ja va 2  s .co m*/
    Integer maxY = 0;
    for (int i = 0; i < asientos.length; i++) {
        if (asientos[i].getPosX() > maxX) {
            maxX = asientos[i].getPosX();
        }
        if (asientos[i].getPosY() > maxY) {
            maxY = asientos[i].getPosY();
        }
    }
    //los tamaos de sillas
    Integer sizeX = pHall.getWidth() / maxX;
    Integer sizeY = pHall.getHeight() / maxY;

    Boolean[][] matrix = new Boolean[maxX][maxY];

    //sillas
    for (int i = 0; i < asientos.length; i++) {
        JButton btn = new JButton("btn_" + Integer.toString(i));
        btn.setText(asientos[i].getName());
        btn.setLocation(sizeX * (asientos[i].getPosX() - 1), sizeY * (asientos[i].getPosY() - 1));
        btn.setSize(sizeX - SPACER, sizeY - SPACER);
        btn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chairPressed(evt);
            }
        });
        matrix[asientos[i].getPosX() - 1][asientos[i].getPosY() - 1] = true;
        pHall.add(btn);
    }
    //pasillos
    for (int x = 0; x < maxX; x++) {
        for (int y = 0; y < maxY; y++) {
            if (matrix[x][y] == null) {
                JPanel panel = new JPanel();
                panel.setBackground(Color.cyan);
                panel.setLocation(x * sizeX - SPACER, y * sizeY - SPACER);
                panel.setSize(sizeX + 2 * SPACER, sizeY + 2 * SPACER);
                pHall.add(panel);
            }
        }
    }
    pHall.repaint();
}

From source file:lockers.FrameCobro.java

private void getRates() {
    JSONArray array = Utils.getJSONArrayFromURL("http://127.0.0.1:8000/Rates/?format=json");

    if (array.size() == 0) {
        this.jLblAvailableLockers.setText("No hay disponibilidad");
    } else {// ww  w  .  j  a va  2s .c o m
        for (Object array1 : array) {
            JButton nuevo = new JButton();
            JSONObject obj2 = (JSONObject) array1;
            System.out.println(obj2.size());
            nuevo.setText(obj2.get("rate_name") + ": " + obj2.get("rate_rate"));
            nuevo.setVisible(true);
            nuevo.setSize(200, 50);
            nuevo.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Object source = e.getSource();

                    if (source instanceof JButton) {
                        JButton btn = (JButton) source;
                        System.out.println("You clicked the button " + btn.getText());
                    }
                }
            });
            this.jPanel1.add(nuevo);
        }

    }

}

From source file:com.excilys.ebi.gatling.recorder.ui.component.RunningFrame.java

public RunningFrame() {

    /* Initialization of the frame */
    setTitle("Gatling Recorder - Running...");
    setMinimumSize(new Dimension(800, 640));
    setLocationRelativeTo(null);//from www  .  ja v a 2  s  .c o  m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    setIconImages(Commons.getIconList());

    /* Declaration & initialization of components */
    JButton btnClear = new JButton("Clear");
    final JButton btnStop = new JButton("Stop !");
    btnStop.setSize(120, 30);

    JScrollPane panelFilters = new JScrollPane(executedEvents);
    panelFilters.setPreferredSize(new Dimension(300, 100));

    stringRequest.setPreferredSize(new Dimension(330, 100));
    JSplitPane requestResponsePane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(stringRequest),
            new JScrollPane(stringResponse));
    final JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, requestResponsePane, stringRequestBody);

    JScrollPane panelHostsCertificate = new JScrollPane(requiredHostsCertificate);
    panelHostsCertificate.setPreferredSize(new Dimension(300, 100));

    /* Layout */
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(10, 5, 0, 0);

    gbc.gridx = 0;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.gridy = 0;
    add(new JLabel("Tag :"), gbc);

    gbc.gridx = 1;
    add(txtTag, gbc);

    gbc.gridx = 2;
    gbc.weightx = 0.5;
    add(btnTag, gbc);

    gbc.gridx = 3;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.weightx = 0.25;
    add(btnClear, gbc);

    gbc.gridx = 4;
    gbc.anchor = GridBagConstraints.LINE_END;
    add(btnStop, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 0;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(new JLabel("Executed Events:"), gbc);

    gbc.gridy = 2;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1;
    gbc.weighty = 0.20;
    gbc.fill = GridBagConstraints.BOTH;
    add(panelFilters, gbc);

    gbc.gridy = 4;
    gbc.weightx = 1;
    gbc.weighty = 0.75;
    gbc.fill = GridBagConstraints.BOTH;
    add(sp, gbc);

    gbc.gridy = 5;
    gbc.weighty = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.anchor = GridBagConstraints.CENTER;
    add(new JLabel("Secured hosts requiring accepting a certificate:"), gbc);

    gbc.gridy = 6;
    gbc.weighty = 0.05;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(panelHostsCertificate, gbc);

    /* Listeners */
    btnTag.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!txtTag.getText().equals(EMPTY)) {
                TagEvent tag = new TagEvent(txtTag.getText());
                events.addElement(tag.toString());
                executedEvents.ensureIndexIsVisible(events.getSize() - 1);
                listEvents.add(tag);
                txtTag.setText(EMPTY);
            }
        }
    });

    executedEvents.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (executedEvents.getSelectedIndex() >= 0) {
                Object obj = listEvents.get(executedEvents.getSelectedIndex());
                if (obj instanceof ResponseReceivedEvent) {
                    ResponseReceivedEvent event = (ResponseReceivedEvent) obj;
                    stringRequest.txt.setText(event.getRequest().toString());
                    stringResponse.txt.setText(event.getResponse().toString());
                    stringRequestBody.txt.setText(new String(event.getRequest().getContent().array()));
                } else {
                    stringRequest.txt.setText(EMPTY);
                    stringResponse.txt.setText(EMPTY);
                    stringRequestBody.txt.setText(EMPTY);
                }
            }
        }
    });

    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            clearOldRunning();
        }
    });

    btnStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            saveScenario();
            proxy.shutdown();
            proxy = null;
            if (!Configuration.getInstance().isConfigurationSkipped())
                getEventBus().post(new ShowConfigurationFrameEvent());
            else
                System.exit(0);
        }
    });
}

From source file:Form.Principal.java

public void PanelUsuarios() {
    int i = 0;//w w  w.  ja va 2s  .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;//  w w w.  ja  v a2  s .c om
    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 ww  w .ja  va  2 s  . c  om*/
    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.swiftexplorer.gui.AboutDlg.java

public static void show(Component parent, HasLocalizedStrings stringsBundle) {
    URI uri = null;// www .  j  a  v a  2  s  .co m
    try {
        uri = new URI("http://www.swiftexplorer.org");
    } catch (URISyntaxException e) {
        logger.error("URL seems to be ill-formed", e);
    }
    final String buttontext = "www.swiftexplorer.org";

    Box mainBox = Box.createVerticalBox();
    mainBox.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));

    StringBuilder sb = loadResource("/about.html");
    JLabel label = new JLabel(sb.toString());
    label.getAccessibleContext().setAccessibleDescription(getTitle(stringsBundle));
    mainBox.add(label);

    if (uri != null) {
        JButton button = new JButton();
        button.setText(buttontext);
        button.setToolTipText(uri.toString());
        button.addActionListener(new OpenUrlAction(uri));
        FontMetrics metrics = button.getFontMetrics(button.getFont());
        if (metrics != null)
            button.setSize(metrics.stringWidth(buttontext), button.getHeight());
        button.getAccessibleContext().setAccessibleDescription(buttontext);
        mainBox.add(button);
    }

    mainBox.add(Box.createVerticalStrut(10));

    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    panel.add(mainBox);

    JOptionPane.showMessageDialog(parent, panel, getTitle(stringsBundle), JOptionPane.INFORMATION_MESSAGE,
            getIcon());
}