/* */ import javax.swing.*; import java.awt.*; import java.awt.event.*; class Peliculas extends JFrame implements ItemListener { //Icono ImageIcon icono = new ImageIcon("1.JPEG"); JLabel imagen = new JLabel(); //Labels JLabel lbltitulo=new JLabel("CATALOGO DE PELICULAS: "); JLabel lblgenero=new JLabel("GENERO: "); JLabel lblduracion=new JLabel("DURACION: "); JLabel lblclasificacion=new JLabel("CLASIFICACION: "); JLabel lblformato=new JLabel("FORMATO"); //JTextFields JTextField jtxtgenero=new JTextField(); JTextField jtxtduracion=new JTextField(); JTextField jtxtclasificacion=new JTextField(); //Combobox String[] code = { "Batman The Dark Knight Rises", "Transformers The Dark Side Of The Moon", "Fast & Furious 6" }; JComboBox combo=new JComboBox(code); //Checkbox JCheckBox chkopcion2D = new JCheckBox("2D",false); JCheckBox chkopcion3D = new JCheckBox("3D",false); JCheckBox chkopcion4D = new JCheckBox("4D",false); JCheckBox chkopcionIMAX = new JCheckBox("IMAX",false); //JButtons JButton cmdlimpiar=new JButton("LIMPIAR"); JButton cmdsalir=new JButton("SALIR"); //Constructor public Peliculas(){ super("CATALOGO DE PELICULAS"); this.setBounds(0,0,800,600); this.setLocationRelativeTo(null); //COMBOBOX combo.setBounds(40,200,180,19); //Labels Posicion y Tamaño lbltitulo.setBounds(300,160,180,19); lblgenero.setBounds(300,200,180,19); lblduracion.setBounds(300,220,180,19); lblclasificacion.setBounds(300,240,180,19); lblformato.setBounds(350,270,189,19); //Labels Posicion y Tamaño jtxtgenero.setBounds(400,200,180,19); jtxtduracion.setBounds(400,220,180,19); jtxtclasificacion.setBounds(400,240,180,19); //Chechkbox chkopcion2D.setBounds(300,300,180,19); chkopcion3D.setBounds(300,320,180,19); chkopcion4D.setBounds(300,340,180,19); chkopcionIMAX.setBounds(400,300,300,25); //Labels Posicion y Tamaño cmdlimpiar.setBounds(300,400,90,19); cmdsalir.setBounds(400,400,90,19); //Imagen imagen.setBounds(100,0,600,145); setLayout(null); ImageIcon icono2 = new ImageIcon(icono.getImage().getScaledInstance(1, 11,Image.SCALE_DEFAULT)); imagen.setIcon(icono); this.add(imagen); this.add(lbltitulo); this.add(lblgenero); this.add(lblduracion); this.add(lblclasificacion); this.add(lblformato); this.add(jtxtgenero); this.add(jtxtduracion); this.add(jtxtclasificacion); add(combo);/* combo.addItem("Batman The Dark Knight Rises"); combo.addItem("Transformers The Dark Side Of The Moon"); combo.addItem("Fast & Furious 6"); combo.addActionListener(this);*/ this.add(cmdlimpiar); this.add(cmdsalir); this.add(chkopcion2D); this.add(chkopcion3D); this.add(chkopcion4D); this.add(chkopcionIMAX); combo.addItemListener(this); cmdsalir.addItemListener(this); this.setVisible(true); } public void itemStateChanged(ItemEvent e){ if (combo.getSelectedItem().equals("Batman The Dark Knight Rises")){ jtxtgenero.setText("Accion"); jtxtduracion.setText("165 min"); jtxtclasificacion.setText("B"); } else if (combo.getSelectedItem().equals("Transformers The Dark Side Of The Moon")){ jtxtgenero.setText("Ciencia Ficcion"); jtxtduracion.setText("155 min"); jtxtclasificacion.setText("A"); } else if (combo.getSelectedItem().equals("Fast & Furious 6")){ jtxtgenero.setText("Accion"); jtxtduracion.setText("90 min"); jtxtclasificacion.setText("B"); } } public static void main(String[] args) { Peliculas P=new Peliculas(); } }
|