|
|
|
|
@ -21,16 +21,23 @@ public class DataChooserWindow extends CustomJDialog
|
|
|
|
|
private final String labels[];
|
|
|
|
|
private final String items[];
|
|
|
|
|
private final JComboBox combos[];
|
|
|
|
|
private final int preselected[];
|
|
|
|
|
|
|
|
|
|
private boolean canceled = false;
|
|
|
|
|
|
|
|
|
|
/** Creates a new instance of DataChooserWindow */
|
|
|
|
|
public DataChooserWindow( JFrame modalFrame, String names[], String data[] )
|
|
|
|
|
{
|
|
|
|
|
this( modalFrame, names, data, null );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DataChooserWindow( JFrame modalFrame, String names[], String data[], int selected[] )
|
|
|
|
|
{
|
|
|
|
|
super( modalFrame, true );
|
|
|
|
|
labels = names;
|
|
|
|
|
items = data;
|
|
|
|
|
combos = new JComboBox[ labels.length ];
|
|
|
|
|
preselected = selected;
|
|
|
|
|
setupComponents();
|
|
|
|
|
if( modalFrame == null )
|
|
|
|
|
{
|
|
|
|
|
@ -67,6 +74,16 @@ public class DataChooserWindow extends CustomJDialog
|
|
|
|
|
*/ gbc.weightx = 1;
|
|
|
|
|
gbc.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
|
|
JComboBox combo = new JComboBox( items );
|
|
|
|
|
int index;
|
|
|
|
|
if( preselected == null )
|
|
|
|
|
{
|
|
|
|
|
index = Math.min( i, items.length );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
index = Math.min( preselected[ i ], items.length );
|
|
|
|
|
}
|
|
|
|
|
combo.setSelectedIndex( index );
|
|
|
|
|
combos[ i ] = combo;
|
|
|
|
|
gbl.setConstraints( combo, gbc );
|
|
|
|
|
cont.add( combo );
|
|
|
|
|
@ -117,11 +134,11 @@ public class DataChooserWindow extends CustomJDialog
|
|
|
|
|
}
|
|
|
|
|
return hash;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
public static void main( String arg[] )
|
|
|
|
|
|
|
|
|
|
/* public static void main( String arg[] )
|
|
|
|
|
{
|
|
|
|
|
String names[] = new String[] { "Nome:", "Morada:", "Telefone:" };
|
|
|
|
|
String data[] = new String[] { "Joao Catita", "Damaiasdg sdfg sdf gsdfs hgf h", "nao tem", "so a noite", "" };
|
|
|
|
|
DataChooserWindow dcw = new DataChooserWindow( null, names, data );
|
|
|
|
|
DataChooserWindow dcw = new DataChooserWindow( null, names, data, new int[] { 3, 2 ,1 } );
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|