本文整理汇总了Java中javax.security.auth.callback.TextOutputCallback.notify方法的典型用法代码示例。如果您正苦于以下问题:Java TextOutputCallback.notify方法的具体用法?Java TextOutputCallback.notify怎么用?Java TextOutputCallback.notify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.security.auth.callback.TextOutputCallback
的用法示例。
在下文中一共展示了TextOutputCallback.notify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleTextOutput
import javax.security.auth.callback.TextOutputCallback; //导入方法依赖的package包/类
protected void handleTextOutput (final TextOutputCallback callback)
throws IOException
{
final JDialog dialog = new JDialog ();
switch (callback.getMessageType ())
{
case TextOutputCallback.ERROR:
dialog.setTitle (messages.getString ("callback.error"));
break;
case TextOutputCallback.WARNING:
dialog.setTitle (messages.getString ("callback.warning"));
break;
case TextOutputCallback.INFORMATION:
dialog.setTitle (messages.getString ("callback.information"));
break;
}
Container content = dialog.getContentPane ();
content.setLayout (new GridBagLayout ());
final JTextArea text = new JTextArea (24, 80);
text.setEditable (false);
text.setText (callback.getMessage ());
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, 0, 1, 1, 1, 1,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets (10, 10, 5, 10), 0, 0));
ActionListener listener = new ActionListener ()
{
public void actionPerformed (ActionEvent ae)
{
dialog.setVisible (false);
synchronized (callback)
{
callback.notify ();
}
}
};
JButton okay = new JButton (messages.getString ("callback.ok"));
okay.setActionCommand ("okay");
okay.addActionListener (listener);
content.add (okay, new GridBagConstraints (0, 1, 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);
}