I am getting my feet wet with java-linux. As a first step, I am simply copying code from the disk included with the book "Java for C/C++ Programmers" by Michael C. DaConta. The first "Hello World" program worked okay but the second one, attached, does not. On my RedHat 5.0 systems (yes, I've upgraded glibc and ld) the dialog comes up but no keyboard input shows up. Any idea why?
// gui classes import java.awt.Frame; import java.awt.TextField; import java.awt.Panel; import java.awt.Button; import java.awt.GridLayout; import java.awt.Event; import java.awt.Color; import java.awt.Label; // our book class import book; // a utility class import java.util.Vector; class bookWindow extends Frame { TextField title; TextField author; TextField publisher; Vector theBooks; int currentIdx; bookWindow() { super("Book Shelf"); // initialize the growable array theBooks = new Vector(3); currentIdx = 0; Panel centerPanel = new Panel(); centerPanel.setLayout(new GridLayout(0, 2)); centerPanel.add(new Label(" Title")); centerPanel.add(title = new TextField(20)); centerPanel.add(new Label(" Author")); centerPanel.add(author = new TextField(20)); centerPanel.add(new Label(" Publisher")); centerPanel.add(publisher = new TextField(20)); add("Center", centerPanel); Panel bottomPanel = new Panel(); bottomPanel.add(new Button("store")); bottomPanel.add(new Button("clear")); bottomPanel.add(new Button("prev")); bottomPanel.add(new Button("next")); bottomPanel.add(new Button("exit")); add("South", bottomPanel); move(200, 100); pack(); show(); } public boolean handleEvent(Event evt) { if (evt.id == Event.ACTION_EVENT) { if ("store".equals(evt.arg)) { book aBook = new book(title.getText(), author.getText(), publisher.getText()); theBooks.addElement(aBook); currentIdx = theBooks.size(); return true; } if ("clear".equals(evt.arg)) { title.setText(""); author.setText(""); publisher.setText(""); return true; } if ("prev".equals(evt.arg)) { if (currentIdx > 0) { book aBook = (book) theBooks.elementAt(--currentIdx); title.setText(aBook.getTitle()); author.setText(aBook.getAuthor()); publisher.setText(aBook.getPublisher()); } return true; } if ("next".equals(evt.arg)) { if (currentIdx < (theBooks.size()-1)) { book aBook = (book) theBooks.elementAt(++currentIdx); title.setText(aBook.getTitle()); author.setText(aBook.getAuthor()); publisher.setText(aBook.getPublisher()); } return true; } if ("exit".equals(evt.arg)) { System.exit(0); } } return true; } } class bookGUI { public static void main(String args[]) { new bookWindow(); } }