Foros del Web » Programación para mayores de 30 ;) » Java »

Problema con visibilidad de un JTextField.

Estas en el tema de Problema con visibilidad de un JTextField. en el foro de Java en Foros del Web. Buenas gente, estoy tratando de hacer un formulario para añadir un proveedor y tengo un problema, uno de los JTextField no me aparece en el ...
  #1 (permalink)  
Antiguo 01/04/2016, 12:08
 
Fecha de Ingreso: marzo-2016
Mensajes: 19
Antigüedad: 8 años, 1 mes
Puntos: 0
Problema con visibilidad de un JTextField.

Buenas gente, estoy tratando de hacer un formulario para añadir un proveedor y tengo un problema, uno de los JTextField no me aparece en el frame y no logro identificar el por que, este es el código:

import javax.swing.*;
import java.awt.*;

public class nuevo_proveedor extends JFrame{
public nuevo_proveedor(){
super ("NUEVO PROVEEDOR.");

this.getContentPane().setLayout (new GridBagLayout());

JLabel nombrejl = new JLabel ("Nombre");
JLabel cedjl = new JLabel ("CC o NIT");
JLabel direccionjl = new JLabel ("Direccion");
JLabel telefono1jl = new JLabel ("Telefono 1");
JLabel telefono2jl = new JLabel ("Telefono 2");
JLabel ciudadjl = new JLabel ("Ciudad");
JLabel marcajl = new JLabel ("Producciones JOLUT");

JButton guardarbtn = new JButton ("Guardar");
JButton verbtn = new JButton ("Ver");
JButton salirbtn = new JButton ("Salir");

JTextField nombretf = new JTextField("",30);
JTextField cctf = new JTextField("", 15);
JTextField direcciontf = new JTextField("",30);
JTextField telefono1tf = new JTextField("", 15);
JTextField telefono2tf = new JTextField("", 15);
JTextField ciudadtf = new JTextField("", 15);

GridBagConstraints gbc = new GridBagConstraints();

gbc.gridx= 0;
gbc.gridy= 0;
gbc.gridwidth= 1;
gbc.gridheight= 1;
this.getContentPane().add (nombrejl, gbc);

gbc.gridx= 1;
gbc.gridy= 0;
gbc.gridwidth= 3;
gbc.gridheight= 1;
gbc.fill= GridBagConstraints.HORIZONTAL;
this.getContentPane().add (nombretf, gbc);

gbc.gridx= 0;
gbc.gridy= 1;
gbc.gridwidth= 1;
gbc.gridheight= 1;
this.getContentPane().add (cedjl, gbc);

gbc.gridx= 1;
gbc.gridy= 1;
gbc.gridwidth= 1;
gbc.gridheight= 1;
gbc.fill= GridBagConstraints.HORIZONTAL;
this.getContentPane().add (cctf, gbc);

gbc.gridx= 2;
gbc.gridy= 1;
gbc.gridwidth= 1;
gbc.gridheight= 1;
this.getContentPane().add (ciudadjl, gbc);

gbc.gridx= 3;
gbc.gridy= 1;
gbc.gridwidth= 1;
gbc.gridheight= 1;
gbc.fill= GridBagConstraints.HORIZONTAL;
this.getContentPane().add (ciudadtf, gbc);

gbc.gridx= 0;
gbc.gridy= 2;
gbc.gridwidth= 1;
gbc.gridheight= 1;
this.getContentPane().add (direccionjl, gbc);

gbc.gridx= 1;
gbc.gridy= 2;
gbc.gridwidth= 3;
gbc.gridheight= 1;
gbc.fill= GridBagConstraints.HORIZONTAL;
this.getContentPane().add (ctf, gbc);

gbc.gridx= 0;
gbc.gridy= 3;
gbc.gridwidth= 1;
gbc.gridheight= 1;
this.getContentPane().add (telefono1jl, gbc);

gbc.gridx= 1;
gbc.gridy= 3;
gbc.gridwidth= 1;
gbc.gridheight= 1;
gbc.fill= GridBagConstraints.HORIZONTAL;
this.getContentPane().add (telefono1tf, gbc);

gbc.gridx= 2;
gbc.gridy= 3;
gbc.gridwidth= 1;
gbc.gridheight= 1;
this.getContentPane().add (telefono2jl, gbc);

gbc.gridx= 3;
gbc.gridy= 3;
gbc.gridwidth= 1;
gbc.gridheight= 1;
gbc.fill= GridBagConstraints.HORIZONTAL;
this.getContentPane().add (telefono2tf, gbc);

gbc.gridx= 1;
gbc.gridy= 4;
gbc.gridwidth= 1;
gbc.gridheight= 1;
this.getContentPane().add (guardarbtn, gbc);

gbc.gridx= 2;
gbc.gridy= 4;
gbc.gridwidth= 1;
gbc.gridheight= 1;
this.getContentPane().add (verbtn, gbc);

gbc.gridx= 3;
gbc.gridy= 4;
gbc.gridwidth= 1;
gbc.gridheight= 1;
this.getContentPane().add (salirbtn, gbc);

gbc.gridx= 3;
gbc.gridy= 5;
gbc.gridwidth= 1;
gbc.gridheight= 1;
gbc.anchor= GridBagConstraints.EAST;
this.getContentPane().add (marcajl, gbc);

this.setVisible (true);
this.pack();
this.setDefaultCloseOperation (EXIT_ON_CLOSE);
}
public static void main (String args[]){
nuevo_proveedor ventana= new nuevo_proveedor();
}
}

El JTextField que no me aparece es el "cctf", de antemano gracias por la ayuda.
  #2 (permalink)  
Antiguo 01/04/2016, 12:18
 
Fecha de Ingreso: enero-2009
Ubicación: Kandor
Mensajes: 209
Antigüedad: 15 años, 3 meses
Puntos: 11
Respuesta: Problema con visibilidad de un JTextField.

creo que tienes un dedazo this.getContentPane().add (ctf, gbc); le falta una c

Etiquetas: string, visibilidad
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 15:05.