Declaración De Un Panel
package GUI;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
importjavax.swing.*;
/**
* @author ESAD
*/
public class panel {
public static void main (String args[]){
JFrame frame=new JFrame("Marco / Frame");
frame.setLocation(200, 200);
frame.setVisible(true);
frame.setSize(500,500);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
JPanelpnl = new javax.swing.JPanel();
pnl.setBackground(Color.CYAN);
JPanel pnl2 = new javax.swing.JPanel();
pnl2.setBackground(Color.MAGENTA);
pnl2.setBorder(javax.swing.BorderFactory.createTitledBorder("Bordecon titulo"));
JPanel pnl3 = new javax.swing.JPanel();
pnl3.setBackground(Color.ORANGE);
frame.add(pnl, BorderLayout.PAGE_START);
frame.add(pnl2, BorderLayout.CENTER);
frame.add(pnl3, BorderLayout.PAGE_END);
}
}
Declaración de un marco
package GUI;
import javax.swing.JFrame;
/**
* @author ESAD
*/
public class marco {
public static void main (String args[]){
JFrame frame=newJFrame("Marco / Frame");
frame.setLocation(200, 200);
frame.setVisible(true);
frame.setSize(300, 300);
}
}
Declaración Uso de Etiquetas.
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
importjavax.swing.*;
/**
* @author ESAD
*/
public class etiquetas {
public static void main (String args[]){
JFrameframe=new JFrame("Marco / Frame");
frame.setLocation(200, 200);
frame.setVisible(true);
frame.setSize(300, 300);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
JLabel etiq1= new javax.swing.JLabel();
etiq1.setText("Ejemplo1");
etiq1.setFont(new java.awt.Font("Calibri",1, 11));
JLabel etiq2= new javax.swing.JLabel();
etiq2.setText("Ejemplo2");
etiq2.setForeground(Color.yellow);
JLabel etiq3= new javax.swing.JLabel();
etiq3.setText("Ejemplo3");
etiq3.setVisible(false);
frame.add(etiq1, BorderLayout.PAGE_START);
frame.add(etiq2, BorderLayout.CENTER);
frame.add(etiq3, BorderLayout.PAGE_END);
}
}
Declaración de Uso de Botones.package GUI;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
importjavax.swing.*;
/**
* @author ESAD
*/
public class marco {
public static void main (String args[]){
JFrame frame=new JFrame("Marco / Frame");
frame.setLocation(200, 200);
frame.setVisible(true);
frame.setSize(300, 300);frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
JButtonbtn = new javax.swing.JButton();
btn.setText("Boton1");
btn.setMnemonic('B');
JButton btn2 = new javax.swing.JButton();
btn2.setText("Boton2");
btn2.setBackground(Color.red);
JButton btn3 = new javax.swing.JButton();btn3.setText("Boton3");
frame.add(btn, BorderLayout.LINE_START);
frame.add(btn2, BorderLayout.CENTER);
frame.add(btn3, BorderLayout.LINE_END);
}
}
Declaración de uso de casillas de activación
package GUI;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
importjavax.swing.*;
/**
* @author ESAD
*/
publicclass casilla {
public static void main (String args[]){
JFrame frame=new JFrame("Marco / Frame");
frame.setLocation(200, 200);
frame.setVisible(true);
frame.setSize(300, 300);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
JCheckBox check1 = new javax.swing.JCheckBox();...
Regístrate para leer el documento completo.