private void initGui() { setResizable(true); setClosable(true); setMaximizable(true); setTitle("MATRICULAR CURSO"); setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); jlbl_cursos = new JLabel("Cursos:"); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.ipadx = 50; add(jlbl_cursos, gbc); jcbx_cursos = new JComboBox<String>(); cursos = control.getCodigos(); for (String cur : cursos) jcbx_cursos.addItem(cur); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.insets.set(0, 4, 4, 4); add(jcbx_cursos, gbc); jlbl_semestre = new JLabel("Semestre:"); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.insets.set(0, 0, 0, 0); add(jlbl_semestre, gbc); jcbx_semestre = new JComboBox<String>(); jcbx_semestre.addItem("1"); jcbx_semestre.addItem("2"); jcbx_semestre.addItem("3"); gbc.gridx = 1; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.insets.set(0, 4, 4, 4); add(jcbx_semestre, gbc); jlbl_years = new JLabel("Año:"); gbc.gridx = 2; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.insets.set(0, 0, 0, 0); add(jlbl_years, gbc); jcbx_years = new JComboBox<String>(); for (int x = 2020; x > 1990; x--) jcbx_years.addItem(String.valueOf(x)); gbc.gridx = 2; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.insets.set(0, 4, 4, 4); add(jcbx_years, gbc); jlbl_nota = new JLabel("Nota"); gbc.gridx = 3; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.insets.set(0, 0, 0, 0); add(jlbl_nota, gbc); jtxt_nota = new JTextField(5); gbc.gridx = 3; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.insets.set(0, 4, 4, 4); add(jtxt_nota, gbc); jbtn_matricularCurso = new Boton("Matricular"); jbtn_matricularCurso.tipoInsertar(); jbtn_matricularCurso.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { insertar(); } }); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.ipadx = 0; add(jbtn_matricularCurso, gbc); // **************************** gbc.gridx = 0; gbc.gridy = 3; gbc.gridwidth = 4; gbc.gridheight = 1; gbc.weightx = 1; gbc.ipady = 3; gbc.fill = GridBagConstraints.HORIZONTAL; add(new JSeparator(JSeparator.HORIZONTAL), gbc); gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 3; gbc.gridheight = 1; gbc.weightx = 0; gbc.ipady = 0; gbc.fill = GridBagConstraints.HORIZONTAL; add(new JLabel("Cursos matriculados actualmente:"), gbc); jtbl_cursosMatriculadosActualmente = new JTable(); jtbl_cursosMatriculadosActualmente.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jtbl_cursosMatriculadosActualmente.setRowSelectionAllowed(true); jscrl_tabla = new JScrollPane(jtbl_cursosMatriculadosActualmente); jscrl_tabla.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); jscrl_tabla.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); jscrl_tabla.setPreferredSize(new Dimension(0, 150)); gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 4; gbc.gridheight = 3; gbc.weightx = 1; gbc.weighty = 1; gbc.fill = GridBagConstraints.BOTH; add(jscrl_tabla, gbc); jbtn_eliminar = new Boton("Eliminar"); jbtn_eliminar.tipoEliminar(); jbtn_eliminar.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { eliminar(); } }); gbc.gridx = 0; gbc.gridy = 8; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0; gbc.weighty = 0; gbc.fill = GridBagConstraints.NONE; add(jbtn_eliminar, gbc); pack(); setLocation(100, 20); }
private void initGui() { setClosable(true); setResizable(true); setMaximizable(true); setTitle("ADMINISTRADOR DE CURSOS"); setFrameIcon( new ImageIcon( getClass().getResource("/ucr/progra2/proyectoprogramado2/recursos/iconos/cursos.png"))); jtbs_tabs = new JTabbedPane(); jpnl_cursos = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); jlbl_cursosAgregados = new JLabel("Cursos Agregados:"); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 2; gbc.gridheight = 1; gbc.insets = new Insets(4, 4, 4, 4); jpnl_cursos.add(jlbl_cursosAgregados); jcbx_cursoAagregados = new JComboBox<String>(); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 2; gbc.gridheight = 1; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1; jpnl_cursos.add(jcbx_cursoAagregados, gbc); jbtn_mostrar = new Boton("Mostrar"); jbtn_mostrar.tipoBuscar(); jbtn_mostrar.addActionListener(this); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 1; gbc.gridheight = 1; jpnl_cursos.add(jbtn_mostrar, gbc); gbc.gridx = 0; gbc.gridy = 3; gbc.gridwidth = 2; gbc.gridheight = 1; gbc.ipady = 3; jpnl_cursos.add(new JSeparator(JSeparator.HORIZONTAL), gbc); jlbl_codigo = new JLabel("Codigo:"); gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.ipady = 0; jpnl_cursos.add(jlbl_codigo, gbc); jtxt_codigo = new JTextField(10); jtxt_codigo.addFocusListener(this); gbc.gridx = 1; gbc.gridy = 4; gbc.gridwidth = 1; gbc.gridheight = 1; jpnl_cursos.add(jtxt_codigo, gbc); jlbl_nombre = new JLabel("Nombre:"); gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 1; gbc.gridheight = 1; jpnl_cursos.add(jlbl_nombre, gbc); jtxt_nombre = new JTextField(10); jtxt_nombre.addFocusListener(this); gbc.gridx = 1; gbc.gridy = 5; gbc.gridwidth = 1; gbc.gridheight = 1; jpnl_cursos.add(jtxt_nombre, gbc); jlbl_cantidadCreditos = new JLabel("Creditos"); gbc.gridx = 0; gbc.gridy = 6; gbc.gridwidth = 1; gbc.gridheight = 1; jpnl_cursos.add(jlbl_cantidadCreditos, gbc); jtxt_cantidadCreditos = new JTextField(10); jtxt_cantidadCreditos.addFocusListener(this); gbc.gridx = 1; gbc.gridy = 6; gbc.gridwidth = 1; gbc.gridheight = 1; jpnl_cursos.add(jtxt_cantidadCreditos, gbc); gbc.gridx = 0; gbc.gridy = 7; gbc.gridwidth = 2; gbc.gridheight = 1; gbc.ipady = 3; jpnl_cursos.add(new JSeparator(JSeparator.HORIZONTAL), gbc); jbtn_insertar = new Boton("Insertar"); jbtn_insertar.tipoInsertar(); jbtn_insertar.addActionListener(this); gbc.gridx = 0; gbc.gridy = 8; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.ipady = 0; jpnl_cursos.add(jbtn_insertar, gbc); jbtn_modificar = new Boton("Modificar"); jbtn_modificar.tipoModificar(); jbtn_modificar.addActionListener(this); gbc.gridx = 1; gbc.gridy = 8; gbc.gridwidth = 1; gbc.gridheight = 1; jpnl_cursos.add(jbtn_modificar, gbc); jbtn_eliminar = new Boton("Eliminar"); jbtn_eliminar.tipoEliminar(); jbtn_eliminar.addActionListener(this); gbc.gridx = 0; gbc.gridy = 9; gbc.gridwidth = 1; gbc.gridheight = 1; jpnl_cursos.add(jbtn_eliminar, gbc); jbtn_buscar = new Boton("Buscar"); jbtn_buscar.tipoBuscar(); jbtn_buscar.addActionListener(this); gbc.gridx = 1; gbc.gridy = 9; gbc.gridwidth = 1; gbc.gridheight = 1; jpnl_cursos.add(jbtn_buscar, gbc); jbtn_limpiar = new Boton("Limpiar"); jbtn_limpiar.tipoLimpiar(); jbtn_limpiar.addActionListener(this); gbc.gridx = 0; gbc.gridy = 10; gbc.gridwidth = 1; gbc.gridheight = 1; jpnl_cursos.add(jbtn_limpiar, gbc); jtbs_tabs.addTab("Cursos", jpnl_cursos); // **************************** jpnl_cursosMatriculados = new JPanel(); jtbs_tabs.addTab("Cursos Matriculados", jpnl_cursosMatriculados); // **************************** getContentPane().add(jtbs_tabs); // **************************** pack(); setLocation(100, 20); toBack(); }