AMADEUS html plain
This sketchy text is generated by AMADEUS
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
Javadoc
* Dialoogid jah,ei (katkesta) valikutega ja noole omaduste valikutega
*
*
*@author Aleksander Ratushnõi
class AmDialog
public class AmDialog extends JDialog
implements ActionListener, ListSelectionListener
* final static int
dialoogi tuu"bid:
B_OK = 0;
B_YES_NO = 1;
B_YES_NO_CANCEL = 2;
B_SELECT_CANCEL = 3;
B_REPLACE_FIND_CANCEL = 4;
B_OK_CANCEL = 5;
lisatud uue baaskeele dialoogi jaoks
B_RESTORE_CANCEL = 6;
B_DEFAULT_PACKAGE_CANCEL = 7;
JK 11.12.2009 uus projekt
nupu numbrid:
YES=1;
NO=2;
CANCEL=3;
OK=4;
SELECT = 5;
REPLACE = 6; // lisatud uus tulemuse tüüp
FIND = 7; // lisatud uus tulemuse tüüp
RESTORE = 8;
PACKAGE = 9;
DEFAULT = 10;
* private JButton
yButton = new JButton(AmLocale.Yes());
nButton = new JButton(AmLocale.No());
cButton = new JButton(AmLocale.Cancel());
okButton = new JButton(AmLocale.Ok());
selButton = new JButton(AmLocale.Select());
repButton = new JButton(AmLocale.Replace()); // lisatud (replace nupp)
finButton = new JButton(AmLocale.Find()); // lisatud (find nupp)
restoreButton = new JButton(AmLocale.Restore()); // lisatud (restore nupp)
defaultButton = new JButton(AmLocale.Default());
JK 11.12.2009 uus projekt
packageButton = new JButton(AmLocale.Package());
JK 11.12.2009 uus projekt
private AmList list;
private int tulemus;
nupu number, mida vajutati;
konstruktoris pannakse 0, seab: actionPerformed()
//CheckboxGroup cbg;
Javadoc
* Konstruktor
*
*@param parent ülemus
*@param title Dialoogi pealkiri
*@param mode Dialoogi välimus - jah,ei / jah, ei, katkesta
*@param dialog_label tekst, mis tuleb dialoogaknasse
konstruktorid*
AmDialog(Frame parent, String title, int dialog_type,String dialog_label)
konstruktor
super(parent, title, true);
ei lase muud teha, kui vastata
super(parent, title, false);// jaa"b tolgendama
tulemus = 0;
teha paneelid: u"lemine, keskmine, alumine (nuppudele)
JPanel northPanel = new JPanel();
dialoogi u"lemine osa
keskmine dialoogi osa, antakse dialog_labelis peale reavahetust:
JPanel centerPanel = new JPanel();
JPanel bottomPanel = new JPanel();
dialoogi alumine (nuppude) osa
layout ja koht raamis parent
getContentPane().setLayout(new BorderLayout());
Dimension pSize = parent.getSize();
Point loc = parent.getLocation();
loc.x += pSize.width/3;
loc.y += pSize.height/3;
setLocation(loc);
panna paneelidele tekstid
int newline = dialog_label.indexOf('\n');
? (newline < 0)
northPanel.add("North",
new JLabel(dialog_label, JLabel.CENTER));
<======
northPanel.add("North",
new JLabel(dialog_label.substring(0,newline), JLabel.CENTER));
centerPanel.add("North",
new JLabel(dialog_label.substring(newline+1,
dialog_label.length()), JLabel.CENTER));
??dialog_type
lisada paneelidele nupud ja nende kuularid
? B_OK:
bottomPanel.add(okButton);
okButton.addActionListener(this);
<======
? B_YES_NO:
bottomPanel.add(yButton);
yButton.addActionListener(this);
bottomPanel.add(nButton);
nButton.addActionListener(this);
<======
? B_YES_NO_CANCEL:
bottomPanel.add(yButton);
yButton.addActionListener(this);
bottomPanel.add(nButton);
nButton.addActionListener(this);
bottomPanel.add(cButton);
cButton.addActionListener(this);
<======
? B_DEFAULT_PACKAGE_CANCEL:
bottomPanel.add(defaultButton);
defaultButton.addActionListener(this);
bottomPanel.add(packageButton);
packageButton.addActionListener(this);
bottomPanel.add(cButton);
cButton.addActionListener(this);
<======
? B_RESTORE_CANCEL:
bottomPanel.add(restoreButton);
restoreButton.addActionListener(this);
bottomPanel.add(cButton);
cButton.addActionListener(this);
<======
lisada paneelid
//add("Center",centerPanel);
getContentPane().add(centerPanel, "Center");
//add("North",northPanel);
getContentPane().add(northPanel, "North");
//add("South",bottomPanel);
getContentPane().add(bottomPanel, "South");
final AmDialog d = this;
lisada dialoogi akna kuular
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){d.dispose();}
});
d.pack();
suurus
Dimension size = d.getSize();
int l = 15*d.getTitle().length();
? (size.width < l)
size.width = l;
d.setSize(size);
d.show();
AmDialog(Frame parent, String title, int dialog_type,String dialog_label, AmList llist)
konstruktor (loeteluga dialoog)
super(parent, title, true);
list = llist;
teha paneelid: u"lemine, keskmine, alumine (nuppudele)
keskmine dialoogi osa
JPanel centerPanel = new JPanel();
dialoogi nuppude osa
JPanel bottomPanel = new JPanel();
JPanel northPanel = new JPanel();
layout
getContentPane().setLayout(new BorderLayout());
panna paneelidele tekstid
int newline = dialog_label.indexOf('\n');
? (newline < 0)
northPanel.add("North", new JLabel(dialog_label, JLabel.CENTER));
<======
northPanel.add("North",
new JLabel(dialog_label.substring(0,newline), JLabel.CENTER));
northPanel.add("North",
new JLabel(dialog_label.substring(newline+1,
dialog_label.length()), JLabel.CENTER));
??dialog_type
lisada paneelidele nupud ja kuularid
? B_SELECT_CANCEL:
bottomPanel.add(selButton);
selButton.addActionListener(this);
bottomPanel.add(cButton);
cButton.addActionListener(this);
list.addListSelectionListener(this);
centerPanel.add(list);
<======
lisada paneelid
getContentPane().add("Center",centerPanel);
getContentPane().add("North",northPanel);
getContentPane().add("South",bottomPanel);
final AmDialog d = this;
lisada AmDialoogi akna kuular
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){d.dispose();}
});
d.pack();
suurus
Dimension size = d.getSize();
int l = 15*d.getTitle().length();
? (size.width < l)
size.width = l;
d.setSize(size);
koht raamis parent
Dimension pSize = parent.getSize();
Point loc = parent.getLocation();
loc.x += pSize.width/2 - size.width/2;
loc.y += pSize.height/2 - size.height/2;
setLocation(loc);
d.show();
public int getTulemus()
<======tulemus
nupu number, mida vajutati
public void actionPerformed(ActionEvent event)
vajutati mingit nuppu
Object source = event.getSource();
nupp, millelt see teade pa"rit on
? (source==list) || (source==selButton)
tulemus = SELECT; dispose();
<======
? (source==yButton)
tulemus = YES; dispose();
<======
? (source==nButton)
tulemus = NO; dispose();
<======
? (source==cButton)
tulemus = CANCEL; dispose();
<======
? (source==okButton)
tulemus = OK; dispose();
<======
? (source==repButton)
tulemus = REPLACE; dispose();
<======
? (source==finButton)
tulemus = FIND; dispose();
<======
? (source==restoreButton)
tulemus = RESTORE; dispose();
<======
? (source==defaultButton)
tulemus = DEFAULT; dispose();
<======
? (source==packageButton)
tulemus = PACKAGE; dispose();
public void valueChanged(ListSelectionEvent evt)
//tulemus = SELECT; dispose();
REITSAKAS:
String f,fi;
lisatud, uued muutujad
AmDialog(Frame parent, String title, int dialog_type)
lisatud, uus konstruktor
super(parent, title, true);
JTextField repl,reply;
defineeritakse tekstiväljade muutujad
tulemus = 0;
JPanel northPanel = new JPanel();
JPanel centerPanel = new JPanel();
JPanel bottomPanel = new JPanel();
getContentPane().setLayout(new BorderLayout());
Dimension pSize = parent.getSize();
Point loc = parent.getLocation();
loc.x += pSize.width/3;
loc.y += pSize.height/3;
setLocation(loc);
repl = new JTextField (8);
defineeritakse uus tekstiväli
reply = new JTextField (8);
defineeritakse uus tekstiväli
northPanel.add("North",new JLabel (AmLocale.Replace ()));
northPanel.add("North", repl);
centerPanel.add("North",new JLabel (AmLocale.with ()));
centerPanel.add("North", reply);
??dialog_type
? B_REPLACE_FIND_CANCEL:
selles lõigus lisatakse
bottomPanel.add(repButton);
nupud ja nende kuulajad
repButton.addActionListener(this);
bottomPanel.add(finButton);
finButton.addActionListener(this);
bottomPanel.add(cButton);
cButton.addActionListener(this);
<======
getContentPane().add("Center",centerPanel);
getContentPane().add("North",northPanel);
getContentPane().add("South",bottomPanel);
final AmDialog d = this;
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){d.dispose();
}
});
d.pack();
Dimension size = d.getSize();
int l = 15*d.getTitle().length();
? size.width < l
size.width = l;
d.setSize(size);
d.show();
f = repl.getText();
//System.out.println("F vaartus replace:"+f);
võetakse tekstiväljale sisestatud tekst
fi = reply.getText();
võetakse tekstiväljale sisestatud tekst
NT -uue baaskeele lisamine
AmDialog(Frame parent, int dialog_type,String title,String boxtext)
lisatud, uus konstruktor()-uue baaskeele lisamine
super(parent, title,true);
JTextField lisa;
defineeritakse tekstiväljade muutujad
tulemus = 0;
JPanel northPanel = new JPanel();
JPanel centerPanel = new JPanel();
JPanel bottomPanel = new JPanel();
getContentPane().setLayout(new BorderLayout());
Dimension pSize = parent.getSize();
Point loc = parent.getLocation();
loc.x += pSize.width/3;
loc.y += pSize.height/3;
setLocation(loc);
lisa = new JTextField (8);
defineeritakse uus tekstiväli
//northPanel.add("North",new JLabel (AmLocale.InsertLangName ()));
northPanel.add("North",new JLabel (boxtext));
northPanel.add("North", lisa);
bottomPanel.add(okButton);
nupud ja nende kuulajad
okButton.addActionListener(this);
bottomPanel.add(cButton);
cButton.addActionListener(this);
//
??dialog_type
? B_OK_CANCEL:
selles lõigus lisatakse
bottomPanel.add(okButton);
nupud ja nende kuulajad
okButton.addActionListener(this);
bottomPanel.add(cButton);
cButton.addActionListener(this);
<======
getContentPane().add("Center",centerPanel);
getContentPane().add("North",northPanel);
getContentPane().add("South",bottomPanel);
final AmDialog d = this;
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
d.dispose();
}
});
d.pack();
Dimension size = d.getSize();
int l = 15*d.getTitle().length();
? size.width < l
size.width = l;
d.setSize(size);
d.show();
f = lisa.getText();
võetakse tekstiväljale sisestatud tekst