当前位置: 首页>>代码示例>>Java>>正文


Java NameCallback.notify方法代码示例

本文整理汇总了Java中javax.security.auth.callback.NameCallback.notify方法的典型用法代码示例。如果您正苦于以下问题:Java NameCallback.notify方法的具体用法?Java NameCallback.notify怎么用?Java NameCallback.notify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.security.auth.callback.NameCallback的用法示例。


在下文中一共展示了NameCallback.notify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleName

import javax.security.auth.callback.NameCallback; //导入方法依赖的package包/类
protected void handleName (final NameCallback 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.NORTHEAST,
                                                   GridBagConstraints.VERTICAL,
                                                   new Insets (10, 10, 15, 5), 0, 0));

  final JTextField name = new JTextField ();
  name.setColumns (20);
  String _name;
  if ((_name = callback.getDefaultName ()) != null)
    name.setText (_name);
  content.add (name, new GridBagConstraints (1, 0, 1, 1, 1, 1,
                                             GridBagConstraints.NORTHWEST,
                                             GridBagConstraints.BOTH,
                                             new Insets (10, 5, 15, 10), 0, 0));

  ActionListener listener = new ActionListener ()
    {
      public void actionPerformed (ActionEvent ae)
      {
        String cmd = ae.getActionCommand ();
        if (cmd.equals ("okay"))
          callback.setName (name.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, 1, 2, 1, 0, 0,
                                                GridBagConstraints.SOUTHEAST,
                                                GridBagConstraints.NONE,
                                                new Insets (0, 10, 10, 10), 0, 0));

  dialog.setResizable (false);
  dialog.pack ();
  dialog.setVisible (true);
  dialog.getRootPane ().setDefaultButton (okay);
  waitForInput (dialog, callback);
}
 
开发者ID:vilie,项目名称:javify,代码行数:60,代码来源:SwingCallbackHandler.java


注:本文中的javax.security.auth.callback.NameCallback.notify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。