I’m currently writing some maths software in which I wanted to be able to use Greek letters as well as Roman. Since Java uses Unicode, this was no problem internally. But how could the user input Greek as well as Roman characters, through a standard US/UK keyboard, and without obscure and slow character codes?
So I wrote a widget which had 25 buttons, labelled with the lower case Greek letters. It has an instance variable which is a reference to a textfield. When the user clicks a button, the corresponding character is appended to that textfield, and focus is placed on that textfield, ready for the next keystroke.
Here it is:
/**
* This is a UI widget supporting the input of Greek letters
* It produces a 5 X 5 grid of buttons, labelled with lower case Greek letters
* When a button is clicked, the corresponding letter is appended to a supplied
* text field
* @author Walter Milner
*/
public class GreekLetterWidget extends JComponent implements ActionListener {
private MyButton[] buttons = new MyButton[25];
private MyTextField textField;
/**
* make an instance, of size 100 by 100
* @param textField The textfield to which the letter will be appended
*/
public GreekLetterWidget(MyTextField textField) {
this.textField = textField;
setLayout(new GridLayout(5, 5));
setSize(100, 100);
// Greek letter buttons
char[] c = new char[1];
c[0] = ‘\u03B1′;
String s = new String(c);
Insets inset = new Insets(1, 1, 1, 1);
for (int i = 0; i < 25; i++) {
buttons[i] = new MyButton(s);
buttons[i].setToolTipText(s);
c[0]++;
s = new String(c);
buttons[i].setMargin(inset);
buttons[i].addActionListener(this);
add(buttons[i]);
}
}
public void setField(MyTextField target)
{
textField=target;
}
public void actionPerformed(ActionEvent e) {
Object obj = e.getSource();
textField.setText(textField.getText() + ((MyButton) obj).getText());
textField.requestFocus();
}
}
This looks like:

screenshot
glw = new GreekLetterWidget(funcTextField);
c.gridx = 3;
c.gridy = 0;
c.gridheight = 2;
add(glw, c);
The setTextField() method is provided so that this can be used with more than one text field in a dialog. The textfields need to have a focuslistener, and in the gainFocus, setTextField is called with that text field as the parameter. That means that when the user clicks on a textfield, from then on GreekLetter button clicks go into that text field.

Just heard the news. Things like The Crystal World, The Drowned World, The Atrocity Exhibition, Crash, The Day of Creation, The Terminal Beach were incredibly good. His visions were surreal, obsessive, neurotic, fascinating, and his writing exposed the stuff in our heads as being far weirder than we might care for, so that the most bizarre was in fact recognisable and familar.
ended at close of play on Friday, just when Barclays was saying ‘I don’t know why you’re all selling my shares, there’s nothing wrong with us.. Really.. Stop selling.. Please”








