Facebook
From Insensitive Cat, 4 Years ago, written in Plain Text.
This paste is a reply to Untitled from Sludgy Bee - go back
Embed
Viewing differences between Untitled and Re: Untitled
package ui;

import javax.swing.JFrame;

public class Test {

        public static void main(String[] args) {

                JFrame frame = new MiFrame("Test v1.0");
                frame.getContentPane().add(new MiPanel("Esto es un test :)"));
test:"));
                frame.setVisible(true);
        }

}

-------------------------------------------------

package ui;

import javax.swing.JFrame;

public class MiFrame extends JFrame {

        public MiFrame(String titulo) {
                super(titulo);
                initUI();
        }

        private void initUI() {
                setSize(600, 400);
                setLocationRelativeTo(null);
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
}

--------------------------------------------------

package ui;

import java.awt.BorderLayout;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class MiPanel extends JPanel {

        public MiPanel(String titulo) {
                initUI(titulo);
        }

        private void initUI(String titulo) {
                setLayout(new BorderLayout());
                
                Box datos1 = Box.createHorizontalBox();
                JLabel tituloLabel = new JLabel(titulo);
                datos1.add(tituloLabel);
                datos1.add(Box.createHorizontalStrut(10));
                datos1.add(new JTextField(30));
                
                Box datos2 = Box.createHorizontalBox();
                JLabel tituloLabel2 = new JLabel(titulo);
                datos2.add(tituloLabel2);
                datos2.add(Box.createHorizontalStrut(10));
                datos2.add(new JTextField(30));
                
                Box botonera = Box.createHorizontalBox();
                botonera.add(Box.createHorizontalGlue());
                botonera.add(new JButton("OK"));
                botonera.add(Box.createHorizontalStrut(10));
                botonera.add(new JButton("Cancel"));
                
                Box vertical = Box.createVerticalBox();
                vertical.add(datos1);
                vertical.add(Box.createVerticalStrut(20));
                vertical.add(datos2);
                vertical.add(Box.createVerticalStrut(50));
                vertical.add(botonera);
                
                add(vertical, BorderLayout.CENTER);
                
                JLabel tituloTitulo = new JLabel("TITULO DE TITULOS:");
                add(tituloTitulo, BorderLayout.NORTH);
                                
        }
        
}