Java Reference
In-Depth Information
};
btnQuit.addActionListener(al);
pnlButtons.add(btnQuit);
pnlRight.add(pnlButtons, BorderLayout.SOUTH);
pnlLayout.add(pnlRight, BorderLayout.EAST);
return pnlLayout;
}
public static void main(String[] args)
{
Runnable r = new Runnable()
{
@Override
public void run()
{
JFrame
f
=
new
JFrame("ChatClient");
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setContentPane(createGUI());
f.pack();
f.setResizable(false);
f.setVisible(true);
}
};
EventQueue.invokeLater(r);
}
}
Listing9-3 ' s ChatClient classconsistsofconstant/nonconstantfields,a JPanel
createGUI() class method for creating this application's graphical user interface
(GUI), and a main() method for creating the GUI and running the application.
The GUI-creation code presents a couple of items that I didn't discuss in Chapter 7
(for brevity):
• The java.awt.Component class declares a void setFocus-
able(boolean focusable) method for setting a component's focus-
able state. In other words, it determines whether or not the user can tab to
orclickonthecomponenttogivethatcomponentinputfocus(e.g.,lettingthe
Search WWH ::




Custom Search