import java.awt.*;
import java.awt.event.*;
public class SelectDialog
extends Dialog
{
private List l;
// private SelResult res;
private String[] choices;
public SelectDialog( Frame parent, String title, String text,
String[] choices/*, SelResult res */) {
super( parent, title, true);
// this.res = res;
this.choices = choices;
if( choices == null) {
opKO();
return;
}
// add( "North", new MultiLabel( text));
add( "Center", l = new LocalList());
addWindowListener(
new WindowAdapter() {
public void windowClosing( WindowEvent event) {
opKO();
}
} );
Panel p = new Panel();
p.setLayout(new FlowLayout(FlowLayout.CENTER));
Button b = new Button("OK");
b.addActionListener(
new ActionListener() {
public void actionPerformed( ActionEvent event) {
opOK();
}
} );
p.add(b);
Button b2= new Button("Cancel");
b.addActionListener(
new ActionListener() {
public void actionPerformed( ActionEvent event) {
opKO();
}
} );
p.add(b2);
add("South", p);
pack();
show();
}
private void opOK() {
// res.pos = l.getSelectedIndex();
// res.value = ( res.pos == -1) ? null : choices[res.pos];
dispose();
}
private void opKO() {
// res.value = null;
// res.pos = -1;
dispose();
}
class LocalList
extends List
{
public LocalList() {
setMultipleMode( false);
for( int i = 0; i < choices.length; i++)
add( choices[i]);
addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent event) {
opOK();
}
} );
}
}
}
import java.awt.event.*;
public class SelectDialog
extends Dialog
{
private List l;
// private SelResult res;
private String[] choices;
public SelectDialog( Frame parent, String title, String text,
String[] choices/*, SelResult res */) {
super( parent, title, true);
// this.res = res;
this.choices = choices;
if( choices == null) {
opKO();
return;
}
// add( "North", new MultiLabel( text));
add( "Center", l = new LocalList());
addWindowListener(
new WindowAdapter() {
public void windowClosing( WindowEvent event) {
opKO();
}
} );
Panel p = new Panel();
p.setLayout(new FlowLayout(FlowLayout.CENTER));
Button b = new Button("OK");
b.addActionListener(
new ActionListener() {
public void actionPerformed( ActionEvent event) {
opOK();
}
} );
p.add(b);
Button b2= new Button("Cancel");
b.addActionListener(
new ActionListener() {
public void actionPerformed( ActionEvent event) {
opKO();
}
} );
p.add(b2);
add("South", p);
pack();
show();
}
private void opOK() {
// res.pos = l.getSelectedIndex();
// res.value = ( res.pos == -1) ? null : choices[res.pos];
dispose();
}
private void opKO() {
// res.value = null;
// res.pos = -1;
dispose();
}
class LocalList
extends List
{
public LocalList() {
setMultipleMode( false);
for( int i = 0; i < choices.length; i++)
add( choices[i]);
addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent event) {
opOK();
}
} );
}
}
}
- duplicates
-
JDK-4051281 Problem compiling when inner class references a private method
-
- Closed
-
- relates to
-
JDK-4059604 javac hangs
-
- Closed
-
-
JDK-4059619 Compiler hangs (no output) on given source code (anon. inner classes + serial?)
-
- Closed
-
-
JDK-4059555 javac hangs when compiling file
-
- Closed
-