Example usage for javax.swing JLabel setSize

List of usage examples for javax.swing JLabel setSize

Introduction

In this page you can find the example usage for javax.swing JLabel 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[] argv) throws Exception {
    final String title = "Testing: \u30CD";

    JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    JLabel label = new JLabel(title);
    label.setSize(200, 100);
    frame.setContentPane(label);//from   w w w  .  j  av  a 2  s . c  o m
    frame.pack();
    frame.setVisible(true);

}

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);/*from  www. j av  a  2s. c om*/
    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  w w.  j a v a 2  s  .  co  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:task5.deneme.java

private JFrame get_MYIMAGE() {
    JFrame frame = new JFrame("picture");
    frame.setSize(img.getWidth(), img.getHeight());
    JLabel l = new JLabel();
    l.setSize(img.getWidth(), img.getHeight());
    l.setIcon((new ImageIcon(img)));
    frame.add(l);//from  w  w w  . ja  va  2s  . com
    frame.setVisible(true);
    return frame;
}

From source file:battleheartlegacybuilder.mainWindow.java

private void buildGridskills() {
    int xPosition = 0;
    int nextRow = 0;

    for (int i = 0; i < notPassiveSkillsNumber; i++) {
        JLabel label = new JLabel("");
        label.setSize(50, 50);
        if (i == 4 || i == 8) {
            nextRow += 60;// w ww.  j  a v a 2  s  .  co m
            xPosition = 0;
        }
        label.setLocation((xPosition * 60) + 5, 30 + nextRow);
        xPosition++;

        label.setIcon(new javax.swing.ImageIcon(
                getClass().getResource("/media/images/OtherImages/skillNotSlected.png")));
        this.pnl_skillsGrids.add(label);
        ingameClassLabelsSkills.add(label);
    }
}

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * Displays Splash Screen//from   ww w .  j a v  a2  s  .c om
 * 
 * @return Splash Screen Reference
 */
public static JWindow showSplash() {

    JWindow splash = new JWindow();
    splash.setSize(400, 250);
    splash.setLayout(null);

    JLabel status = new JLabel("Developed by Yohan Liyanage, 2008");
    JLabelAppender.setLabel(status);
    status.setFont(new Font("sansserif", Font.PLAIN, 10));
    status.setSize(350, 30);
    status.setLocation(10, 220);
    splash.add(status);

    JLabel lbl = new JLabel(
            new ImageIcon(ClassLoader.getSystemResource("META-INF/resources/nebula-startup.png")));
    lbl.setSize(400, 250);
    lbl.setLocation(0, 0);
    splash.add(lbl);

    splash.setVisible(true);
    splash.setLocationRelativeTo(null);

    return splash;
}

From source file:Installer.java

public Installer(File targetDir) {
    ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE);
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    JPanel logoSplash = new JPanel();
    logoSplash.setLayout(new BoxLayout(logoSplash, BoxLayout.Y_AXIS));
    try {/*  w  w  w  .  j a  v a2 s . c o  m*/
        // Read png
        BufferedImage image;
        image = ImageIO.read(Installer.class.getResourceAsStream("logo.png"));
        ImageIcon icon = new ImageIcon(image);
        JLabel logoLabel = new JLabel(icon);
        logoLabel.setAlignmentX(CENTER_ALIGNMENT);
        logoLabel.setAlignmentY(CENTER_ALIGNMENT);
        logoLabel.setSize(image.getWidth(), image.getHeight());
        if (!QUIET_DEV) // VIVE - hide oculus logo
            logoSplash.add(logoLabel);
    } catch (IOException e) {
    } catch (IllegalArgumentException e) {
    }

    userHomeDir = System.getProperty("user.home", ".");
    osType = System.getProperty("os.name").toLowerCase();
    if (osType.contains("win")) {
        isWindows = true;
        appDataDir = System.getenv("APPDATA");
    }

    version = "UNKNOWN";
    try {
        InputStream ver = Installer.class.getResourceAsStream("version");
        if (ver != null) {
            String[] tok = new BufferedReader(new InputStreamReader(ver)).readLine().split(":");
            if (tok.length > 0) {
                jar_id = tok[0];
                version = tok[1];
            }
        }
    } catch (IOException e) {
    }

    // Read release notes, save to file
    String tmpFileName = System.getProperty("java.io.tmpdir") + releaseNotePathAddition + "Vivecraft"
            + version.toLowerCase() + "_release_notes.txt";
    releaseNotes = new File(tmpFileName);
    InputStream is = Installer.class.getResourceAsStream("release_notes.txt");
    if (!copyInputStreamToFile(is, releaseNotes)) {
        releaseNotes = null;
    }

    JLabel tag = new JLabel("Welcome! This will install Vivecraft " + version);
    tag.setAlignmentX(CENTER_ALIGNMENT);
    tag.setAlignmentY(CENTER_ALIGNMENT);
    logoSplash.add(tag);

    logoSplash.add(Box.createRigidArea(new Dimension(5, 20)));
    tag = new JLabel("Select path to minecraft. (The default here is almost always what you want.)");
    tag.setAlignmentX(CENTER_ALIGNMENT);
    tag.setAlignmentY(CENTER_ALIGNMENT);
    logoSplash.add(tag);

    logoSplash.setAlignmentX(CENTER_ALIGNMENT);
    logoSplash.setAlignmentY(TOP_ALIGNMENT);
    this.add(logoSplash);

    JPanel entryPanel = new JPanel();
    entryPanel.setLayout(new BoxLayout(entryPanel, BoxLayout.X_AXIS));

    Installer.targetDir = targetDir;
    selectedDirText = new JTextField();
    selectedDirText.setEditable(false);
    selectedDirText.setToolTipText("Path to minecraft");
    selectedDirText.setColumns(30);
    entryPanel.add(selectedDirText);
    JButton dirSelect = new JButton();
    dirSelect.setAction(new FileSelectAction());
    dirSelect.setText("...");
    dirSelect.setToolTipText("Select an alternative minecraft directory");
    entryPanel.add(dirSelect);

    entryPanel.setAlignmentX(LEFT_ALIGNMENT);
    entryPanel.setAlignmentY(TOP_ALIGNMENT);
    infoLabel = new JLabel();
    infoLabel.setHorizontalTextPosition(JLabel.LEFT);
    infoLabel.setVerticalTextPosition(JLabel.TOP);
    infoLabel.setAlignmentX(LEFT_ALIGNMENT);
    infoLabel.setAlignmentY(TOP_ALIGNMENT);
    infoLabel.setVisible(false);

    fileEntryPanel = new JPanel();
    fileEntryPanel.setLayout(new BoxLayout(fileEntryPanel, BoxLayout.Y_AXIS));
    fileEntryPanel.add(infoLabel);
    fileEntryPanel.add(entryPanel);

    fileEntryPanel.setAlignmentX(CENTER_ALIGNMENT);
    fileEntryPanel.setAlignmentY(TOP_ALIGNMENT);
    this.add(fileEntryPanel);
    this.add(Box.createVerticalStrut(5));

    JPanel optPanel = new JPanel();
    optPanel.setLayout(new BoxLayout(optPanel, BoxLayout.Y_AXIS));
    optPanel.setAlignmentX(LEFT_ALIGNMENT);
    optPanel.setAlignmentY(TOP_ALIGNMENT);

    //Add forge options
    JPanel forgePanel = new JPanel();
    forgePanel.setLayout(new BoxLayout(forgePanel, BoxLayout.X_AXIS));
    //Create forge: no/yes buttons
    useForge = new JCheckBox();
    AbstractAction actf = new updateActionF();
    actf.putValue(AbstractAction.NAME, "Install Vivecraft with Forge " + FORGE_VERSION);
    useForge.setAction(actf);
    forgeVersion = new JComboBox();
    if (!ALLOW_FORGE_INSTALL)
        useForge.setEnabled(false);
    useForge.setToolTipText(
            "<html>" + "If checked, installs Vivecraft with Forge support. The correct version of Forge<br>"
                    + "(as displayed) must already be installed.<br>" + "</html>");

    //Add "yes" and "which version" to the forgePanel
    useForge.setAlignmentX(LEFT_ALIGNMENT);
    forgeVersion.setAlignmentX(LEFT_ALIGNMENT);
    forgePanel.add(useForge);
    //forgePanel.add(forgeVersion);

    // Profile creation / update support
    createProfile = new JCheckBox("", true);
    AbstractAction actp = new updateActionP();
    actp.putValue(AbstractAction.NAME, "Create Vivecraft launcher profile");
    createProfile.setAction(actp);
    createProfile.setAlignmentX(LEFT_ALIGNMENT);
    createProfile.setSelected(true);
    createProfile.setToolTipText("<html>"
            + "If checked, if a Vivecraft profile doesn't already exist within the Minecraft launcher<br>"
            + "one is added. Then the profile is selected, and this Vivecraft version is set as the<br>"
            + "current version.<br>" + "</html>");

    useShadersMod = new JCheckBox();
    useShadersMod.setAlignmentX(LEFT_ALIGNMENT);
    if (!ALLOW_SHADERSMOD_INSTALL)
        useShadersMod.setEnabled(false);
    AbstractAction acts = new updateActionSM();
    acts.putValue(AbstractAction.NAME, "Install Vivecraft with ShadersMod 2.3.29");
    useShadersMod.setAction(acts);
    useShadersMod.setToolTipText("<html>" + "If checked, sets the vivecraft profile to use ShadersMod <br>"
            + "support." + "</html>");

    useHydra = new JCheckBox("Razer Hydra support", false);
    useHydra.setAlignmentX(LEFT_ALIGNMENT);
    if (!ALLOW_HYDRA_INSTALL)
        useHydra.setEnabled(false);
    useHydra.setToolTipText("<html>"
            + "If checked, installs the additional Razor Hydra native library required for Razor Hydra<br>"
            + "support." + "</html>");

    useHrtf = new JCheckBox("Enable binaural audio (Only needed once per PC)", false);
    useHrtf.setToolTipText("<html>"
            + "If checked, the installer will create the configuration file needed for OpenAL HRTF<br>"
            + "ear-aware sound in Minecraft (and other games).<br>"
            + " If the file has previously been created, you do not need to check this again.<br>"
            + " NOTE: Your sound card's output MUST be set to 44.1Khz.<br>" + " WARNING, will overwrite "
            + (isWindows ? (appDataDir + "\\alsoft.ini") : (userHomeDir + "/.alsoftrc")) + "!<br>"
            + " Delete the " + (isWindows ? "alsoft.ini" : "alsoftrc") + " file to disable HRTF again."
            + "</html>");
    useHrtf.setAlignmentX(LEFT_ALIGNMENT);

    //Add option panels option panel
    forgePanel.setAlignmentX(LEFT_ALIGNMENT);

    //optPanel.add(forgePanel);
    //optPanel.add(useShadersMod);
    optPanel.add(createProfile);
    optPanel.add(useHrtf);
    this.add(optPanel);

    this.add(Box.createRigidArea(new Dimension(5, 20)));

    instructions = new JLabel("", SwingConstants.CENTER);
    instructions.setAlignmentX(CENTER_ALIGNMENT);
    instructions.setAlignmentY(TOP_ALIGNMENT);
    instructions.setForeground(Color.RED);
    instructions.setPreferredSize(new Dimension(20, 40));
    this.add(instructions);

    this.add(Box.createVerticalGlue());
    JLabel github = linkify("Vivecraft is open source. find it on Github",
            "https://github.com/jrbudda/Vivecraft_111", "Vivecraft 1.11 Github");
    JLabel wiki = linkify("Vivecraft home page", "http://www.vivecraft.org", "Vivecraft Home");
    JLabel donate = linkify("If you think Vivecraft is awesome, please consider donating.",
            "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JVBJLN5HJJS52&lc=US&item_name=jrbudda&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)",
            "jrbudda's Paypal");
    JLabel optifine = linkify("Vivecraft includes OptiFine for performance. Consider donating to them as well.",
            "http://optifine.net/donate.php", "http://optifine.net/donate.php");

    github.setAlignmentX(CENTER_ALIGNMENT);
    github.setHorizontalAlignment(SwingConstants.CENTER);
    wiki.setAlignmentX(CENTER_ALIGNMENT);
    wiki.setHorizontalAlignment(SwingConstants.CENTER);
    donate.setAlignmentX(CENTER_ALIGNMENT);
    donate.setHorizontalAlignment(SwingConstants.CENTER);
    optifine.setAlignmentX(CENTER_ALIGNMENT);
    optifine.setHorizontalAlignment(SwingConstants.CENTER);

    this.add(Box.createRigidArea(new Dimension(5, 20)));
    this.add(github);
    this.add(wiki);
    this.add(donate);
    this.add(optifine);

    this.setAlignmentX(LEFT_ALIGNMENT);
    updateFilePath();
    updateInstructions();
}

From source file:org.forester.archaeopteryx.ControlPanel.java

private void addSequenceRelationBlock() {
    final JLabel spacer = new JLabel("");
    spacer.setSize(1, 1);
    add(spacer);//from w w  w. j  av a  2  s  . com
    final JLabel mainLabel = new JLabel("Sequence relations to display");
    final JLabel typeLabel = customizeLabel(new JLabel("(type) "), getConfiguration());
    typeLabel.setFont(ControlPanel.js_font.deriveFont(7));
    getSequenceRelationTypeBox().setFocusable(false);
    _sequence_relation_type_box.setFont(ControlPanel.js_font);
    if (!_configuration.isUseNativeUI()) {
        _sequence_relation_type_box.setBackground(Constants.BUTTON_BACKGROUND_COLOR_DEFAULT);
        _sequence_relation_type_box.setForeground(Constants.BUTTON_TEXT_COLOR_DEFAULT);
    }
    _sequence_relation_type_box.setRenderer(new ListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(final JList list, final Object value, final int index,
                final boolean isSelected, final boolean cellHasFocus) {
            final Component component = new DefaultListCellRenderer().getListCellRendererComponent(list, value,
                    index, isSelected, cellHasFocus);
            if ((value != null) && (value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE)) {
                ((DefaultListCellRenderer) component).setText(SequenceRelation
                        .getPrintableNameByType((SequenceRelation.SEQUENCE_RELATION_TYPE) value));
            }
            return component;
        }
    });
    final GridBagLayout gbl = new GridBagLayout();
    _sequence_relation_type_box.setMinimumSize(new Dimension(115, 17));
    _sequence_relation_type_box.setPreferredSize(new Dimension(115, 20));
    final JPanel horizGrid = new JPanel(gbl);
    horizGrid.setBackground(getBackground());
    horizGrid.add(typeLabel);
    horizGrid.add(_sequence_relation_type_box);
    add(customizeLabel(mainLabel, getConfiguration()));
    add(horizGrid);
    add(getSequenceRelationBox());
    if (_configuration.doDisplayOption(Configuration.show_relation_confidence)) {
        addCheckbox(Configuration.show_relation_confidence,
                _configuration.getDisplayTitle(Configuration.show_relation_confidence));
        setCheckbox(Configuration.show_relation_confidence,
                _configuration.doCheckOption(Configuration.show_relation_confidence));
    }
}

From source file:Form.Principal.java

public void PanelUsuarios() {
    int i = 0;//w ww . j ava 2  s .  co 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  a 2s. 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));
}