/**
* @author Igor Kholodov, Bristol Community College
*
* <code>application</code> package is a namespace for the classes
* of the application.
*/
package application;
//import javax.swing.JOptionPane;
//import javax.swing.JDialog;
//import javax.swing.JTextField;
import javax.swing.*;
import java.beans.*; //property change stuff
import java.awt.*;
import java.awt.event.*;
/* 1.4 example used by PanelWithTabs.java. */
class DialogViewOptions
extends JDialog
implements ActionListener
{
FrameRadioButtons mFrameRadioButtons;
JFrame mFrame;
PanelWithTabs tabbedPanel;
boolean mResult = false;
/** Creates custom dialog. */
//DEBUG//public DialogViewOptions(FrameRadioButtons aFrame)
public DialogViewOptions(JFrame aFrame, FrameRadioButtons aFrameRadioButtons)
{
super(aFrame, true);
mFrame = aFrame;
mFrameRadioButtons = aFrameRadioButtons;
//Create and set up the content pane.
tabbedPanel = new PanelWithTabs(aFrame, this);
tabbedPanel.setOpaque(true); //content panes must be opaque
// Set the content pane, which has all GUI components of our dialog
aFrame.setContentPane(tabbedPanel);
aFrame.setTitle("Dialog View Options Title");
//Handle window closing correctly.
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
}//constructor DialogViewOptions
/** This method handles events for dialog UI components. */
public void actionPerformed(ActionEvent event)
{
Object obj = event.getSource();
if (obj == tabbedPanel.mButOK)
{
// OK
mResult = true;
mFrameRadioButtons.setBottomLabelText("[OK] " + getText());
}
else if (obj == tabbedPanel.mButCancel)
{
// Cancel
mResult = false;
mFrameRadioButtons.setBottomLabelText("[Cancel]");
}
mFrame.setVisible(false); // either button hides the dialog
}// method actionPerformed
/** Gets the text displayed by the text field. */
public String getText()
{
return tabbedPanel.getText();
}
/** Sets the text of the text field. */
public void setText(String aText)
{
tabbedPanel.setText(aText);
}//void setText
/** Gets the result. */
public boolean getResult()
{
return mResult;
}
}//class DialogViewOptions