Java Reference
In-Depth Information
invisible. We check whether the dialogue is already defined by checking whether
the reference to it is null or not.
if (searchDialog == null )
{
searchDialog = new SearchDialog( this );
dataTransfer = new DataTransferObject();
}
The variables searchDialog and dataTransfer are previously declared, e.g.
private SearchDialog searchDialog;
private DataTransferObject dataTransfer;
but not instantiated using new .Wenow list the classes SearchDialog and Data-
TransferObject .
File: its/Dialogs/SearchDialog.java
package its.Dialogs;
1.
2.
3.
import java.awt.*;
import java.awt.event.*;
4.
import javax.swing.*;
5.
6.
7.
public class SearchDialog extends JDialog
{
8.
9.
private JPanel mainPanel
= new JPanel();
10.
private JTextField searchTextField = new JTextField();
11.
private JRadioButton yesButton
= new JRadioButton("Yes");
12.
private JRadioButton noButton
= new JRadioButton("No");
13.
private JButton searchButton
= new JButton("Find");
14.
private JButton cancelButton
= new JButton("Cancel");
15.
private DataTransferObject dataTransfer;
16.
private ButtonGroup group = new ButtonGroup();
17.
18.
public SearchDialog(Frame frame)
19.
{
20.
super (frame,"Search dialog", true );
21.
22.
JLabel questionS
= new JLabel("search word:");
JLabel questionCS
= new JLabel("case-sensitive?");
23.
JLabel filler
= new JLabel();
24.
25.
26.
this .getContentPane().setLayout( new BorderLayout());
this .setLocation(300,300);
27.
this .getContentPane().add(mainPanel,BorderLayout.CENTER);
28.
29.
Search WWH ::




Custom Search