Problema con JFrames (no se ven)

Mario
31 de Diciembre del 2005
Hola a tod@s. A continuación os pongo parte de mi código; para el primer caso quiero que aparezca el formulario de MakeTorrentForm, cuando ejecuto el programa aparece el frame pero no se ve su contenido (botones, formularios,....,nada) para el segundo caso, SetPath me pasa lo mismo, pero si hago clic en el frame como para cambiar su tamaño, el formulario empieza a verse.

Gracias.

Estas son las clases del primer error:
//Esta clase crea el formulario:
package clientebittorrent.torrents;

import java.util.LinkedList;
import java.io.*;
import javax.swing.*;

import clientebittorrent.gui.MakeTorrentForm;

public class MakeTorrent {

private String path;
private String name;
private String torrentName;
private int pieceLength;
private String announceURL;
private int size;
private LinkedList hashs;
private File file;
private RandomAccessFile rf;

public MakeTorrent(String path_) {
path = path_;
file = new File(path);
name = file.getName();
JFrame makeForm = new MakeTorrentForm(this);
makeForm.setBounds(100,100,400,300);
makeForm.setVisible(true);
}
}
//Esta clase es el formulario

package clientebittorrent.gui;

import javax.swing.*;

import clientebittorrent.torrents.MakeTorrent;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MakeTorrentForm extends JFrame {
public MakeTorrentForm() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}

private MakeTorrent maker;
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField jTextField1 = new JTextField();
JLabel jLabel3 = new JLabel();
JTextField jTextField2 = new JTextField();
JLabel jLabel4 = new JLabel();
JComboBox jComboBox1;
JButton jButton1 = new JButton();

public MakeTorrentForm(MakeTorrent maker_) {
maker = maker_;
this.setVisible(true);
this.setSize(400,400);
}

private void jbInit() throws Exception {
String[] posibilities = {"32 KB","64 KB","128 KB","256 KB","512 KB","1.0 MB","2.0 MB"};
jComboBox1 = new JComboBox(posibilities);
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setText("Propiedades del Torrent");
jLabel1.setBounds(new Rectangle(0, 2, 400, 15));
jLabel2.setText("Nombre");
jLabel2.setBounds(new Rectangle(8, 44, 90, 20));
this.getContentPane().setLayout(null);
jButton1.addActionListener(new MakeTorrentForm_jButton1_actionAdapter(this));
this.getContentPane().add(jLabel1, null);
jButton1.setBounds(new Rectangle(137, 232, 114, 43));
jButton1.setActionCommand("Aceptar");
jButton1.setText("Aceptar");
jComboBox1.setBounds(new Rectangle(108, 133, 114, 26));
jLabel4.setText("Tamaño de piezas");
jLabel4.setBounds(new Rectangle(8, 126, 98, 35));
jTextField2.setBounds(new Rectangle(158, 81, 211, 24));
jLabel3.setText("URL Rastreador (Announcer)");
jLabel3.setBounds(new Rectangle(7, 80, 152, 25));
jTextField1.setBounds(new Rectangle(125, 45, 127, 20));
this.getContentPane().add(jLabel2, null);
this.getContentPane().add(jLabel3);
this.getContentPane().add(jTextField1);
this.getContentPane().add(jTextField2);
this.getContentPane().add(jLabel4);
this.getContentPane().add(jComboBox1);
this.getContentPane().add(jButton1);

}

public void jButton1_actionPerformed(ActionEvent e) {
String name = jTextField1.getText();
String announce = jTextField2.getText();
int index = jComboBox1.getSelectedIndex();
System.out.println("INDICE: "+index);
int pieceLength = 0;
switch (index){
case 0: pieceLength = 32768; break;
case 1: pieceLength = 65536; break;
case 2: pieceLength = 131072; break;
case 3: pieceLength = 262144; break;
case 4: pieceLength = 524288; break;
case 5: pieceLength = 1048576; break;
case 6: pieceLength = 2097152; break;
}
if (name != "" && announce != ""){
name += ".torrent";
//Creamos el torrent.
//maker.setTorrent(name,announce,pieceLength);
//this.setVisible(false);
}
}
}


class MakeTorrentForm_jButton1_actionAdapter implements ActionListener {
private MakeTorrentForm adaptee;
MakeTorrentForm_jButton1_actionAdapter(MakeTorrentForm adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}

//Pir último esta es la clase con el formulario que se me ve si toco lo de cambiar el tamaño.

package clientebittorrent.gui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;

import clientebittorrent.core.MainProperties;

public class SetPath extends JFrame {
MainProperties prop;

public SetPath(MainProperties prop_) {
prop = prop_;
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}

private void jbInit() throws Exception {
this.getContentPane().setLayout(null);
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setText("Selección de directorio de descargas");
jLabel1.setBounds(new Rectangle(6, 5, 288, 33));
jButton1.addActionListener(new SetPath_jButton1_actionAdapter(this));
this.getContentPane().add(jLabel1);
jButton1.setBounds(new Rectangle(98, 119, 99, 39));
jButton1.setActionCommand("Aceptar");
jButton1.setText("Aceptar");
this.getContentPane().add(jTextField1);
this.getContentPane().add(jButton1);
jTextField1.setBounds(new Rectangle(26, 67, 238, 29));
jButton1.setVisible(true);
jLabel1.setVisible(true);
jTextField1.setVisible(true);
}

JLabel jLabel1 = new JLabel();
JTextField jTextField1 = new JTextField();
JButton jButton1 = new JButton();

public void jButton1_actionPerformed(ActionEvent e) {
String valor = jTextField1.getText();
File f = new File(valor);
if (f.isDirectory()){
prop.setValue("path",valor);
}
setVisible(false);
}
}


class SetPath_jButton1_actionAdapter implements ActionListener {
private SetPath adaptee;
SetPath_jButton1_actionAdapter(SetPath adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}



mario
31 de Diciembre del 2005
Bueno pues me acabo de dar cuenta por qué la primera parte no funcionaba; está claro, no me he dado cuenta y he creado dos constructores de la clase MakeTorrentForm y lanzaba el que simplemente crea el objeto y no crea los elementos.
De todas formas sigo teniendo el problema de la tercera clase (SetPath), que no se ve hasta que cambio el tamaño.

Muchas gracias y perdón por el error.