Está en la página 1de 18

PROGRAMACION ORIENTADA A OBJETO I

SEMANA 8

Nombre del
Fecha de entrega
DESARROLLO
Se desea diseñar una interfaz gráfica que permita mostrar un formulario para reservar citas de revisiones
técnicas de automóviles

a.El diseño es libre al igual que el uso de componentes y eventos gráficos.

b. Se deben pedir los datos personales del propietario del vehículo. Nombres, RUT, teléfono y dirección.
Considere que la región debe venir cargada por una lista desplegable

c. Configure algún elemento para reservar horas y fechas de la revisión técnica.

d. Solicite modelo, año marca del automóvil.

DESARROLLO
IMPORT JAVAX.SWING.*;

IMPORT JAVA.AWT.*;

IMPORT JAVA.AWT.EVENT.*;

IMPORT JAVAX.SWING.JOPTIONPANE;

IMPORT JAVA.TEXT.DATEFORMAT;

IMPORT JAVA.UTIL.DATE;
IMPORT JAVAX.SWING.JFORMATTEDTEXTFIELD;

OPCIONES GRAFICAS

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import javax.swing.JOptionPane;

import java.text.DateFormat;

import java.util.Date; -----------------LIBRERIAS DE FECHA.

import javax.swing.JFormattedTextField;
FORMULARIO

public class FormularioAtencionCliente {

private JFrame frame;

private JTextField textField;

private JTextField textField_1;

private JTextField textField_2;

private JTextField textField_3;

private JTextField textField_4;

private JSpinner jsNota;

private SpinnerNumberModel snm;

/**

* Lanza la aplicación
*

*/

public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {

public void run() { try {

FormularioAtencionCliente window = new FormularioAtencionCliente();

window.frame.setVisible(true);

} catch (Exception e) {

e.printStackTrace();

});

/**

* Crea la aplicación

*/

public FormularioAtencionCliente() {

initialize();

/**

* Inicializa los contenidos del frame


*/

private void initialize() {

frame = new JFrame();

frame.setTitle("Formulario reserva al Cliente");

frame.setBounds(100, 100, 730, 689);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getContentPane().setLayout(null);

textField = new JTextField();

textField.setBounds(180, 28, 250, 20);

frame.getContentPane().add(textField);

textField.setColumns(10);

JLabel lblName = new JLabel("NOMBRES");

lblName.setBounds(65, 31, 110, 14);

frame.getContentPane().add(lblName);

JLabel lblPhone = new JLabel("TELEFONO");

lblPhone.setBounds(65, 68, 56, 14);

frame.getContentPane().add(lblPhone);

textField_1 = new JTextField();

textField_1.setBounds(180, 65, 86, 20);

frame.getContentPane().add(textField_1);

textField_1.setColumns(10);

JLabel lblEmailId = new JLabel("RUT");

lblEmailId.setBounds(65, 115, 46, 14);

frame.getContentPane().add(lblEmailId);
textField_2 = new JTextField();

textField_2.setBounds(180, 112, 147, 20);

frame.getContentPane().add(textField_2);

textField_2.setColumns(10);

JLabel lblAddress = new JLabel("DIRECCION");

lblAddress.setBounds(65, 162, 76, 14);

frame.getContentPane().add(lblAddress);

JTextArea textArea_1 = new JTextArea();

textArea_1.setBounds(180, 157, 212, 40);

frame.getContentPane().add(textArea_1);

JLabel lblFechaId = new JLabel("FECHA");

lblFechaId.setBounds(65, 210, 46, 14);

frame.getContentPane().add(lblFechaId);

-------------------------------- TEXTBOX---------- HORA--------------------------

SE ASIGNA MODO DATE Y SE AGREGAN LA CABECERA LAS LIBRERIAS.

JFormattedTextField textField_4 = new


JFormattedTextField(DateFormat.getDateInstance(DateFormat.SHORT));

textField_4.setValue(new Date());

textField_4.setBounds(180, 210, 180, 20);

frame.getContentPane().add(textField_4);

textField_4.setColumns(10);

JButton btnClear = new JButton("BORRAR");

btnClear.setBounds(312, 487, 89, 23);

frame.getContentPane().add(btnClear);

JLabel lblOccupation = new JLabel("HORA");


lblOccupation.setBounds(65, 280, 67, 14);

frame.getContentPane().add(lblOccupation);

TEXTBOX PARA INGRESAR DATOS

JLabel lblOccupation1 = new JLabel("MODELO");

lblOccupation1.setBounds(65, 380, 67, 14);

frame.getContentPane().add(lblOccupation1);

JLabel lblOccupation4 = new JLabel("AÑO");

lblOccupation4.setBounds(65, 350, 67, 14);

frame.getContentPane().add(lblOccupation4);

JLabel lblOccupation5 = new JLabel("REGION");

lblOccupation5.setBounds(65, 240, 67, 14);

frame.getContentPane().add(lblOccupation5);

-------------------------------- COMBOBOX---------- HORA--------------------------

JComboBox<String> comboBox = new

JComboBox<String>(); comboBox.addItem("Seleccionar");

comboBox.addItem("08:00");
comboBox.addItem("09:00");

comboBox.addItem("10:00");

comboBox.addItem("11:00");

comboBox.addItem("12:00");

comboBox.addItem("13:00");

comboBox.addItem("14:00");

comboBox.addItem("16:00");

comboBox.addItem("17:00");

comboBox.addItem("18:00");

-------------------------------- COMBOBOX---------- REGIONES--------------------------

JComboBox<String> comboBox5 = new

JComboBox<String>(); comboBox5.addItem("Seleccionar");

comboBox5.addItem("I REGION");

comboBox5.addItem("II REGION");

comboBox5.addItem("III REGION");

comboBox5.addItem("IV REGION");

comboBox5.addItem("V REGION");

comboBox5.addItem("VI REGION");

comboBox5.addItem("VII REGION");

comboBox5.addItem("VIII REGION");

comboBox5.addItem("IX REGION");

comboBox5.addItem("X REGION");

comboBox5.addItem("XI REGION");

comboBox5.addItem("XII REGION");

comboBox5.addItem("XIII REGION");
comboBox.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

});

comboBox.setBounds(180, 280, 191, 20);

frame.getContentPane().add(comboBox);

JLabel lblReasson = new JLabel("MOTIVO");

lblReasson.setBounds(65, 315, 67, 14);

frame.getContentPane().add(lblReasson);

-------------------------------- COMBOBOX---------- MOTIVO--------------------------

JComboBox<String> comboBox2 = new

JComboBox<String>(); comboBox2.addItem("Seleccionar");

comboBox2.addItem("MANTENCION");

comboBox2.addItem("REVISION");

comboBox2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

});

comboBox2.setBounds(180, 315, 191, 20);

frame.getContentPane().add(comboBox2);
-------------------------------- COMBOBOX---------- MODELO--------------------------

JComboBox<String> comboBox3 = new

JComboBox<String>(); comboBox3.addItem("Seleccionar");

comboBox3.addItem("TIIDA");

comboBox3.addItem("SAIL");

comboBox3.addItem("LUV");

comboBox3.addItem("TERRANO");

comboBox3.addItem("T3");

comboBox3.addItem("HUNTER");

comboBox3.addItem("NAVARA");

comboBox3.addItem("ORLANDO");

comboBox3.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

});

comboBox3.setBounds(180, 380, 191, 20);

frame.getContentPane().add(comboBox3);

-------------------------------- COMBOBOX---------- AÑO--------------------------

JComboBox<String> comboBox4 = new

JComboBox<String>(); comboBox4.addItem("Seleccionar");

comboBox4.addItem("2019");
comboBox4.addItem("2020");

comboBox4.addItem("2021");

comboBox4.addItem("2022");

comboBox4.addItem("2023");

comboBox4.addItem("2024");

comboBox4.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

});

comboBox4.setBounds(180, 350, 191, 20);

frame.getContentPane().add(comboBox4);

comboBox5.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

});

comboBox5.setBounds(180, 240, 191, 20);

frame.getContentPane().add(comboBox5);

JButton btnSubmit = new JButton("Enviar");

btnSubmit.setBackground(Color.WHITE);

btnSubmit.setForeground(Color.BLACK);

btnSubmit.setBounds(150, 487, 89, 23);

frame.getContentPane().add(btnSubmit);

btnSubmit.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

if(textField.getText().isEmpty()||(textField_1.getText().isEmpty())||
(textField_2.getText().isEmpty())||(textArea_1.getText().isEmpty())||

(textField_3.getText().isEmpty())||(textArea_1.getText().isEmpty())||

(textField_4.getText().isEmpty())||(textArea_1.getText().isEmpty())||

(comboBox.getSelectedItem().equals("Seleccionar"))||

(comboBox2.getSelectedItem().equals("Seleccionar"))||

(comboBox3.getSelectedItem().equals("Seleccionar"))||

(comboBox4.getSelectedItem().equals("Seleccionar")))

JOptionPane.showMessageDialog(null, "falta ingresar informacion");

else

JOptionPane.showMessageDialog(null,"gracias por la informacion");

});

btnClear.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

textField_1.setText(null); textField_2.setText(null);

textField.setText(null); textArea_1.setText(null);

comboBox.setSelectedItem("Seleccionar");

});

COMBOBOX REGION.
COMBOBOX HORA
COMBOBOX MOTIVO

COMBOBOX AÑO VEHICULO.


COMBOBOX MODELO VEHICULO.

SE GUARDAN LOS DATOS O SE ENVIAN EN ESTE CASO PERO SI FALTA INFORMACION


Enviado correctamente
REFERENCIAS BIBLIOGRÁFICAS
1.- contenido semana 8.

También podría gustarte