📄 cmainwindow.java
字号:
// SMSLib for Java// An open-source API Library for sending and receiving SMS via a GSM modem.// Copyright (C) 2002-2006, Thanasis Delenikas, Athens/GREECE// Web Site: http://www.smslib.org//// SMSLib is distributed under the LGPL license.//// This library is free software; you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public// License as published by the Free Software Foundation; either// version 2.1 of the License, or (at your option) any later version.// // This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU// Lesser General Public License for more details.// // You should have received a copy of the GNU Lesser General Public// License along with this library; if not, write to the Free Software// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA//// SMSServer for Java GUI Application.// Please read _README.txt for further information.//package smsserver;import java.awt.*;import java.awt.event.*;import javax.swing.*;class CMainWindow extends JFrame{ private static final long serialVersionUID = 8856877740428098662L; private CSettings settings; private SMSServer SmsServer; private CMainThread service; private CAboutDialog aboutDialog = null; private JMenuBar menuBar; private JMenu fileMenu, aboutMenu; private JMenuItem mniConnect, mniDisconnect, mniExit; private JMenuItem mniAbout; private JLabel lblManuf, lblModel, lblSerialNo, lblIMSI, lblSwVersion, lblBattery, lblSignal, lblStatus; private JTextField txtManuf, txtModel, txtSerialNo, txtIMSI, txtSwVersion, txtStatus; private JProgressBar pgbBattery, pgbSignal; private JLabel lblInFrom, lblInDate, lblInText; private JTextField txtInFrom, txtInDate; private JTextArea txtInText; private JLabel lblOutTo, lblOutDate, lblOutText; private JTextField txtOutTo, txtOutDate; private JTextArea txtOutText; private JLabel lblUpSince, lblTraffic, lblTrafficIn, lblTrafficOut; private JTextField txtUpSince, txtTrafficIn, txtTrafficOut; private JLabel lblInterfaces, lblInterfaceDB, lblInterfaceXML, lblInterfaceRMI; private JLabel lblRawLogs, lblRawInLog, lblRawOutLog; public CMainWindow(SMSServer SmsServer, CSettings settings) { this.SmsServer = SmsServer; this.settings = settings; this.settings.setMainWindow(this); service = new CUserThread(SmsServer, this, settings); setTitle(CConstants.MAIN_WINDOW_TITLE); setSize(750, 580); setLocation(5, 5); getContentPane().setLayout(new GridBagLayout()); menuBar = new JMenuBar(); fileMenu = new JMenu(CConstants.MENU_FILE_MAIN); mniConnect = new JMenuItem(CConstants.MENU_FILE_OPTION_01); mniConnect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { service.connect(true); } }); mniDisconnect = new JMenuItem(CConstants.MENU_FILE_OPTION_02); mniDisconnect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { service.disconnect(true); } }); mniExit = new JMenuItem(CConstants.MENU_FILE_OPTION_99); mniExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); fileMenu.add(mniConnect); fileMenu.add(mniDisconnect); fileMenu.addSeparator(); fileMenu.add(mniExit); menuBar.add(fileMenu); aboutMenu = new JMenu(CConstants.MENU_ABOUT_MAIN); mniAbout = new JMenuItem(CConstants.MENU_ABOUT_OPTION_01); mniAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { if (aboutDialog == null) aboutDialog = new CAboutDialog(CMainWindow.this); aboutDialog.setVisible(true); } }); aboutMenu.add(mniAbout); menuBar.add(aboutMenu); setJMenuBar(menuBar); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.weightx = 100; gbc.weighty = 100; gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.insets.left = 5; gbc.insets.top = 5; gbc.insets.right = 5; JPanel statusPanel = new JPanel(); statusPanel.setLayout(new GridBagLayout()); lblManuf = new JLabel(CConstants.LABEL_MANUFACTURER, SwingConstants.LEFT); txtManuf = new JTextField("", 16); txtManuf.setEditable(false); gbc.gridx = 0; gbc.gridy = 0; statusPanel.add(lblManuf, gbc); gbc.gridx = 1; gbc.gridy = 0; statusPanel.add(txtManuf, gbc); lblModel = new JLabel(CConstants.LABEL_MODEL, SwingConstants.LEFT); txtModel = new JTextField("", 16); txtModel.setEditable(false); gbc.gridx = 0; gbc.gridy = 1; statusPanel.add(lblModel, gbc); gbc.gridx = 1; gbc.gridy = 1; statusPanel.add(txtModel, gbc); lblSerialNo = new JLabel(CConstants.LABEL_SERIALNO, SwingConstants.LEFT); txtSerialNo = new JTextField("", 20); txtSerialNo.setEditable(false); gbc.gridx = 0; gbc.gridy = 2; statusPanel.add(lblSerialNo, gbc); gbc.gridx = 1; gbc.gridy = 2; statusPanel.add(txtSerialNo, gbc); lblIMSI = new JLabel(CConstants.LABEL_IMSI, SwingConstants.LEFT); txtIMSI = new JTextField("", 20); txtIMSI.setEditable(false); gbc.gridx = 0; gbc.gridy = 3; statusPanel.add(lblIMSI, gbc); gbc.gridx = 1; gbc.gridy = 3; statusPanel.add(txtIMSI, gbc); lblSwVersion = new JLabel(CConstants.LABEL_SWVERSION, SwingConstants.LEFT); txtSwVersion = new JTextField("", 20); txtSwVersion.setEditable(false); gbc.gridx = 0; gbc.gridy = 4; statusPanel.add(lblSwVersion, gbc); gbc.gridx = 1; gbc.gridy = 4; statusPanel.add(txtSwVersion, gbc); gbc.insets.top = 15; lblBattery = new JLabel(CConstants.LABEL_BATTERY, SwingConstants.LEFT); pgbBattery = new JProgressBar(0, 100); pgbBattery.setStringPainted(true); gbc.gridx = 0; gbc.gridy = 5; statusPanel.add(lblBattery, gbc); gbc.gridx = 1; gbc.gridy = 5; statusPanel.add(pgbBattery, gbc); gbc.insets.top = 5; lblSignal = new JLabel(CConstants.LABEL_SIGNAL, SwingConstants.LEFT); pgbSignal = new JProgressBar(0, 100); pgbSignal.setStringPainted(true); gbc.gridx = 0; gbc.gridy = 6; statusPanel.add(lblSignal, gbc); gbc.gridx = 1; gbc.gridy = 6; statusPanel.add(pgbSignal, gbc); gbc.insets.top = 15; gbc.insets.bottom = 8; lblStatus = new JLabel(CConstants.LABEL_STATUS, SwingConstants.LEFT); txtStatus = new JTextField(CConstants.STATUS_DISCONNECTED, 20); txtStatus.setEditable(false); txtStatus.setHorizontalAlignment(SwingConstants.CENTER); txtStatus.setFont(new Font("SansSerif", Font.BOLD, 12)); gbc.gridx = 0; gbc.gridy = 7; statusPanel.add(lblStatus, gbc); gbc.gridx = 1; gbc.gridy = 7; statusPanel.add(txtStatus, gbc); statusPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), CConstants.BORDER_MOBILE_INFORMATION)); gbc.anchor = GridBagConstraints.NORTH; gbc.weightx = 100; gbc.weighty = 100; gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.insets.left = 5; gbc.insets.top = 5; getContentPane().add(statusPanel, gbc); gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.weightx = 100; gbc.weighty = 100; gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.insets.left = 5; gbc.insets.top = 5; gbc.insets.right = 5; JPanel incomingPanel = new JPanel(); incomingPanel.setLayout(new GridBagLayout()); lblInFrom = new JLabel(CConstants.LABEL_INCOMING_FROM, SwingConstants.LEFT); txtInFrom = new JTextField("", 16); txtInFrom.setEditable(false); gbc.gridx = 0; gbc.gridy = 0; incomingPanel.add(lblInFrom, gbc); gbc.gridx = 1; gbc.gridy = 0; incomingPanel.add(txtInFrom, gbc); lblInDate = new JLabel(CConstants.LABEL_INCOMING_DATE, SwingConstants.LEFT); txtInDate = new JTextField("", 20); txtInDate.setEditable(false); gbc.gridx = 0; gbc.gridy = 1; incomingPanel.add(lblInDate, gbc); gbc.gridx = 1; gbc.gridy = 1; incomingPanel.add(txtInDate, gbc); gbc.insets.bottom = 19; lblInText = new JLabel(CConstants.LABEL_INCOMING_TEXT, SwingConstants.LEFT); txtInText = new JTextArea(8, 20); txtInText.setEditable(false); txtInText.setLineWrap(true); gbc.gridx = 0; gbc.gridy = 2; incomingPanel.add(lblInText, gbc); gbc.gridx = 1; gbc.gridy = 2; gbc.gridheight = 8; incomingPanel.add(txtInText, gbc); incomingPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), CConstants.BORDER_INCOMING_MESSAGES)); gbc.anchor = GridBagConstraints.NORTH; gbc.weightx = 100; gbc.weighty = 100; gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.insets.left = 5; gbc.insets.top = 5; gbc.insets.bottom = 5; getContentPane().add(incomingPanel, gbc); gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.weightx = 100; gbc.weighty = 100; gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.insets.left = 5; gbc.insets.top = 5; gbc.insets.right = 5; JPanel outgoingPanel = new JPanel(); outgoingPanel.setLayout(new GridBagLayout()); lblOutTo = new JLabel(CConstants.LABEL_OUTGOING_TO, SwingConstants.LEFT); txtOutTo = new JTextField("", 16); txtOutTo.setEditable(false); gbc.gridx = 0; gbc.gridy = 0; outgoingPanel.add(lblOutTo, gbc); gbc.gridx = 1; gbc.gridy = 0; outgoingPanel.add(txtOutTo, gbc); lblOutDate = new JLabel(CConstants.LABEL_OUTGOING_DATE, SwingConstants.LEFT); txtOutDate = new JTextField("", 20); txtOutDate.setEditable(false); gbc.gridx = 0; gbc.gridy = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -