⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loginframe.java

📁 一个类似QQ的在线通讯聊天软件原码,适合初学者参考学习。
💻 JAVA
字号:
package openicq.gui;import java.awt.*;import java.awt.event.*;import javax.swing.*;import openicq.Start;import openicq.data.Resource;import org.javalib.dynamic.localize.Localizable;import org.javalib.gui.image.ImageLoader;import org.javalib.util.TitledList;/** * The <code>LoginFrame</code> class contains the frame for the login * procedure. * @author Hansgeorg Schwibbe * @copyright 2004 */public class LoginFrame extends JFrame implements Localizable, SysTrayAction{  private JPanel contentPane;  protected JMenuBar jMenuBar = new JMenuBar();  protected JMenu jMenuICQ = new JMenu();  protected JMenu jMenuHelp = new JMenu();  protected JMenuItem jMenuItemExit = new JMenuItem();  protected JMenuItem jMenuItemInfo = new JMenuItem();  protected InfoDialog infoDialog;  protected TitledList localized;  protected LoginPanel loginPanel;  protected LoginDocumentPanel docPanel;  /**   * Initializes a new instance of the class <code>LoginFrame</code>.   */  public LoginFrame()  {    try    {      this.setIconImage(ImageLoader.loadImage(Resource.ICON_SOURCE_LOGO, this));    }    catch (Exception ex)    {      System.err.println(this.getClass().getName() + ": " + ex.toString());    }    jMenuItemExit.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        action_closeWindow();      }    });    jMenuItemInfo.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        action_showInfoDialog();      }    });    this.setJMenuBar(jMenuBar);    jMenuBar.add(jMenuICQ);    jMenuICQ.add(jMenuItemExit);    jMenuBar.add(jMenuHelp);    jMenuHelp.add(jMenuItemInfo);    contentPane = (JPanel) this.getContentPane();    loginPanel = new LoginPanel(this);    docPanel = new LoginDocumentPanel(this);    contentPane.setLayout(new BorderLayout());    contentPane.add(loginPanel, BorderLayout.CENTER);    contentPane.add(docPanel, BorderLayout.SOUTH);    setResizable(false);    infoDialog = new InfoDialog(this);    localize();    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();    Dimension frameSize = this.getSize();    if (frameSize.height > screenSize.height)    {      frameSize.height = screenSize.height;    }    if (frameSize.width > screenSize.width)    {      frameSize.width = screenSize.width;    }    this.setLocation((screenSize.width - frameSize.width) / 2,                     (screenSize.height - frameSize.height) / 2);    this.setVisible(true);  }  /**   * (non-Javadoc)   * @see openicq.gui.SysTrayAction#action_closeWindow()   */  public void action_closeWindow()  {    dispose();    System.exit(0);  }  /**   * (non-Javadoc)   * @see openicq.gui.SysTrayAction#action_maximizeWindow()   */  public void action_maximizeWindow()  {    this.setVisible(true);    if (this.getState() == Frame.ICONIFIED)    {      this.setState(Frame.NORMAL);    }  }  /**   * Action 'Open info dialog'   */  protected void action_showInfoDialog()  {    infoDialog.show();  }  /**   * (non-Javadoc)   * @see org.javalib.dynamic.localize.Localizable#localize()   */  public void localize()  {    synchronized (Start.env)    {      localized = Start.env.getLocalizedList();      // Info dialog      infoDialog.localize();      // This frame      this.setTitle(((String[]) localized.get("mainFrame"))[0] + " ("                    + ((String[]) localized.get("login"))[0] + ")");      jMenuICQ.setText(((String[]) localized.get("menubar"))[0]);      jMenuICQ.setMnemonic(((char[]) localized.get("menubarShortkeys"))[0]);      jMenuItemExit.setText(((String[]) localized.get("menubar"))[4]);      char skey = ((char[]) localized.get("menubarShortkeys"))[4];      jMenuItemExit.setAccelerator(KeyStroke.getKeyStroke(skey, Event.CTRL_MASK));      jMenuHelp.setText(((String[]) localized.get("menubar"))[5]);      jMenuHelp.setMnemonic(((char[]) localized.get("menubarShortkeys"))[5]);      jMenuItemInfo.setText(((String[]) localized.get("menubar"))[6]);      skey = ((char[]) localized.get("menubarShortkeys"))[6];      jMenuItemInfo.setAccelerator(KeyStroke.getKeyStroke(skey, Event.CTRL_MASK));      // LoginPanel      loginPanel.accountPanelBorder.setTitle(((String[]) localized.get("login"))[1]);      loginPanel.jLabelUserID.setText(((String[]) localized.get("login"))[2]);      loginPanel.jLabelPassword.setText(((String[]) localized.get("login"))[3]);      loginPanel.jCheckBoxAutoSave.setText(((String[]) localized.get("login"))[4]);      loginPanel.serverPanelBorder.setTitle(((String[]) localized.get("login"))[5]);      loginPanel.jLabelHost.setText(((String[]) localized.get("login"))[6]);      loginPanel.jLabelPort.setText(((String[]) localized.get("login"))[7]);      loginPanel.jCheckBoxAutoLogin.setText(((String[]) localized.get("login"))[8]);      loginPanel.jButtonConnect.setText(((String[]) localized.get("stdButtons"))[7]);      loginPanel.jButtonCancel.setText(((String[]) localized.get("stdButtons"))[1]);      loginPanel.repaint();      // LoginDocumentPanel      docPanel.setDocument(docPanel.getDocument());      // SysTray      String tooltip = ((String[]) localized.get("mainFrame"))[0] + " ("                       + ((String[]) localized.get("login"))[0] + ")";      SysTray.createSystemTray(Resource.ICON_SOURCE_TRAY[8], tooltip, this);    }    // Pack    this.pack();  }  /**   * (non-Javadoc)   * @see java.awt.Window#processWindowEvent(java.awt.event.WindowEvent)   */  protected void processWindowEvent(WindowEvent e)  {    if (e.getID() == WindowEvent.WINDOW_CLOSING && SysTray.hasSysTrayMenu())    {      this.setVisible(false);    }    else if (e.getID() == WindowEvent.WINDOW_CLOSING)    {      this.action_closeWindow();    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -