本文整理汇总了Java中javax.security.auth.callback.TextInputCallback.notify方法的典型用法代码示例。如果您正苦于以下问题:Java TextInputCallback.notify方法的具体用法?Java TextInputCallback.notify怎么用?Java TextInputCallback.notify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.security.auth.callback.TextInputCallback
的用法示例。
在下文中一共展示了TextInputCallback.notify方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleTextInput
import javax.security.auth.callback.TextInputCallback; //导入方法依赖的package包/类
protected void handleTextInput (final TextInputCallback callback)
throws IOException
{
final JDialog dialog = new JDialog ();
Container content = dialog.getContentPane ();
content.setLayout (new GridBagLayout ());
content.add (new JLabel (callback.getPrompt ()),
new GridBagConstraints (0, 0, 1, 1, 0, 0,
GridBagConstraints.NORTHWEST,
GridBagConstraints.NONE,
new Insets (10, 10, 15, 5), 0, 0));
final JTextArea text = new JTextArea (24, 80);
text.setEditable (true);
String _text;
if ((_text = callback.getDefaultText ()) != null)
text.setText (_text);
text.setFont (new Font ("Monospaced", Font.PLAIN, 12));
JScrollPane textPane = new JScrollPane (text,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
content.add (textPane,
new GridBagConstraints (0, 1, 1, 1, 1, 1,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets (5, 10, 5, 10), 0, 0));
ActionListener listener = new ActionListener ()
{
public void actionPerformed (ActionEvent ae)
{
String cmd = ae.getActionCommand ();
if (cmd.equals ("okay"))
callback.setText (text.getText ());
dialog.setVisible (false);
synchronized (callback)
{
callback.notify ();
}
}
};
JPanel buttons = new JPanel ();
buttons.setLayout (new FlowLayout (FlowLayout.RIGHT));
JButton cancel = new JButton (messages.getString ("callback.cancel"));
JButton okay = new JButton (messages.getString ("callback.ok"));
cancel.setActionCommand ("cancel");
cancel.addActionListener (listener);
buttons.add (cancel);
okay.setActionCommand ("okay");
okay.addActionListener (listener);
buttons.add (okay);
content.add (buttons, new GridBagConstraints (0, 2, 1, 1, 0, 0,
GridBagConstraints.SOUTHEAST,
GridBagConstraints.NONE,
new Insets (0, 10, 10, 10), 0, 0));
dialog.setResizable (true);
dialog.pack ();
dialog.setVisible (true);
dialog.getRootPane ().setDefaultButton (okay);
waitForInput (dialog, callback);
}
示例2: handleTextInput
import javax.security.auth.callback.TextInputCallback; //导入方法依赖的package包/类
protected void handleTextInput (final TextInputCallback callback)
throws IOException
{
final JDialog dialog = new JDialog ();
Container content = dialog.getContentPane ();
content.setLayout (new GridBagLayout ());
content.add (new JLabel (callback.getPrompt ()),
new GridBagConstraints (0, 0, 1, 1, 0, 0,
GridBagConstraints.NORTHWEST,
GridBagConstraints.NONE,
new Insets (10, 10, 15, 5), 0, 0));
final JTextArea text = new JTextArea (24, 80);
text.setEditable (true);
String _text;
if ((_text = callback.getDefaultText ()) != null)
text.setText (_text);
text.setFont (new Font ("Monospaced", Font.PLAIN, 12));
JScrollPane textPane = new JScrollPane (text,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
content.add (textPane,
new GridBagConstraints (0, 1, 1, 1, 1, 1,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets (5, 10, 5, 10), 0, 0));
ActionListener listener = new ActionListener ()
{
public void actionPerformed (ActionEvent ae)
{
String cmd = ae.getActionCommand ();
if (cmd.equals ("okay"))
callback.setText (text.getText ());
dialog.setVisible (false);
synchronized (callback)
{
callback.notify ();
}
}
};
JPanel buttons = new JPanel ();
buttons.setLayout (new FlowLayout (FlowLayout.RIGHT));
JButton cancel = new JButton (messages.getString ("callback.cancel"));
JButton okay = new JButton (messages.getString ("callback.ok"));
cancel.setActionCommand ("cancel");
cancel.addActionListener (listener);
buttons.add (cancel);
okay.setActionCommand ("okay");
okay.addActionListener (listener);
buttons.add (okay);
content.add (buttons, new GridBagConstraints (0, 2, 1, 1, 0, 0,
GridBagConstraints.SOUTHEAST,
GridBagConstraints.NONE,
new Insets (0, 10, 10, 10), 0, 0));
dialog.setResizable (true);
dialog.pack ();
dialog.setVisible (true);
dialog.getRootPane ().setDefaultButton (okay);
waitForInput (dialog, callback);
}