Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/01/2013, 16:26
GregLlan
 
Fecha de Ingreso: enero-2013
Ubicación: Chile
Mensajes: 29
Antigüedad: 11 años, 4 meses
Puntos: 0
Exclamación Problema con JFrame

Mi problema es que cuando inicio el codigo me aparece el JFrame sin el componente que agregue, en este caso un Jtexfield. Cuando minimizo y vuelvo a ver el JFrame ahora el jtextfield si aparece.

Les dejo el codigo a continuación, gracias por su ayuda!

Código:
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Point;
import java.awt.Toolkit;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

public final class Frame extends JFrame {
    int array;

    public Frame() throws FileNotFoundException, IOException {
    
    	super("PruebaFrame");
		setVisible(true);
		setResizable(false);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		Point middle = new Point(screenSize.width / 2, screenSize.height / 2);
		Point newLocation = new Point(middle.x - (getContentPane().getWidth() / 2), 
        middle.y - (getContentPane().getHeight() / 2));
		getContentPane().setLocation(newLocation);		
		setSize(650,600);

		InitComponents();}
    					
 public void InitComponents() throws FileNotFoundException, IOException{

    							setLayout(new FlowLayout());
    							//JLabel  PH= new JLabel("Turbidez Rio");
                                final JTextField textfield = new JTextField(2);		
                                       getContentPane().add(textfield);}
 
 public static void main(String[] args) throws FileNotFoundException, IOException {
        System.out.println("Funciona Main");
        new Frame();
    }
}