📄 abstractsocketswingclient.java
字号:
/* ===========================================================
* JDBMonitor : a flexiable JDBC Monitor for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2006-2006, by yang zhongke
*
* Project Info: http://www.cownew.com
*
* 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.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ---------------
* AbstractSocketSwingClient.java
* ---------------
* (C) Copyright 2006-2006, by yang zhongke
*
* Original Author: yang zhongke;
*
* Changes
* -------
*
*/
package com.cownew.JDBMonitor.listenerImpl.sckListenerClient;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
import com.cownew.JDBMonitor.listenerImpl.uicommon.JCownewFrame;
import com.cownew.JDBMonitor.listenerImpl.uicommon.SwingUtils;
public abstract class AbstractSocketSwingClient extends JCownewFrame
{
protected JTextArea textAreaMsg;
protected JMenuItem menuItemStart;
protected JMenuItem menuItemStop;
public AbstractSocketSwingClient()
{
super();
}
protected void initUI()
{
super.initUI();
initMenuBar();
textAreaMsg = new JTextArea();
textAreaMsg.setEditable(false);
JScrollPane scrollPaneMsg = new JScrollPane(textAreaMsg);
container.add(scrollPaneMsg);
}
protected void initMenuBar()
{
JMenuBar menuBar = new JMenuBar();
//Menu "File"
JMenu menuFile = new JMenu();
menuFile.setLabel("File");
JMenuItem menuItemCreateConnect = new JMenuItem();
menuItemCreateConnect.setLabel("CreateConnect...");
menuItemCreateConnect.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
menuItemCreateConnect_actionPerformed(e);
}
});
menuItemStart = new JMenuItem();
menuItemStart.setLabel("Start Monitoring");
menuItemStart.setEnabled(false);
menuItemStart.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
menuItemStart_actionPerformed(e);
}
});
menuItemStop = new JMenuItem();
menuItemStop.setLabel("Stop Monitoring");
menuItemStop.setEnabled(false);
menuItemStop.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
menuItemStop_actionPerformed(e);
}
});
JMenuItem menuItemSave = new JMenuItem();
menuItemSave.setLabel("Save As...");
menuItemSave.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0)
{
menuItemSave_actionPerformed(arg0);
}
});
JMenuItem menuItemExit = new JMenuItem();
menuItemExit.setLabel("Exit");
menuItemExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
dispose();
}
});
menuFile.add(menuItemCreateConnect);
menuItemStart.setAccelerator(KeyStroke.getKeyStroke('S',InputEvent.CTRL_MASK));
menuFile.add(menuItemStart);
menuItemStop.setAccelerator(KeyStroke.getKeyStroke('P',InputEvent.CTRL_MASK));
menuFile.add(menuItemStop);
menuFile.addSeparator();
menuFile.add(menuItemSave);
menuFile.add(menuItemExit);
menuBar.add(menuFile);
//Menu Edit
JMenu menuEdit = new JMenu();
menuEdit.setText("Edit");
JMenuItem menuItemCopy = new JMenuItem();
menuItemCopy.setText("Copy");
menuItemCopy.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0)
{
menuItemCopy_actionPerformed(arg0);
}
});
menuEdit.add(menuItemCopy);
JMenuItem menuItemSelectAll = new JMenuItem();
menuItemSelectAll.setText("SelectAll");
menuItemSelectAll.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0)
{
menuItemSelectAll_actionPerformed(arg0);
}
});
menuEdit.add(menuItemSelectAll);
JMenuItem menuItemFind = new JMenuItem();
menuItemFind.setText("Find...");
menuItemFind.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0)
{
menuItemFind_actionPerformed(arg0);
}
});
menuItemFind.setAccelerator(KeyStroke.getKeyStroke('F',InputEvent.CTRL_MASK));
menuEdit.add(menuItemFind);
JMenuItem menuItemClear = new JMenuItem();
menuItemClear.setText("Clear");
menuItemClear.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0)
{
menuItemClear_actionPerformed(arg0);
}
});
menuItemClear.setAccelerator(KeyStroke.getKeyStroke('R',InputEvent.CTRL_MASK));
menuEdit.add(menuItemClear);
menuBar.add(menuEdit);
//Menu Option
JMenu menuOption = new JMenu();
menuOption.setText("Option");
JCheckBoxMenuItem menuItemScrollLock = new JCheckBoxMenuItem();
menuItemScrollLock.setSelected(false);
menuItemScrollLock.setText("ScrollLock");
menuItemScrollLock.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0)
{
menuItemScrollLock_actionPerformed(arg0);
}
});
menuItemScrollLock.setAccelerator(KeyStroke.getKeyStroke('L',InputEvent.CTRL_MASK));
menuOption.add(menuItemScrollLock);
JMenu menuItemSkin = new JMenu();
menuItemSkin.setLabel("LookAndFeel");
menuOption.add(menuItemSkin);
SwingUtils.initLookAndFeelMenu(this,menuItemSkin);
menuBar.add(menuOption);
//Menu "Help"
JMenu menuHelp = new JMenu();
menuHelp.setText("Help");
JMenuItem menuItemAbout = new JMenuItem();
menuItemAbout.setText("About");
menuItemAbout.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0)
{
menuItemAbout_actionPerformed(arg0);
}
});
menuHelp.add(menuItemAbout);
menuBar.add(menuHelp);
this.setJMenuBar(menuBar);
}
protected void menuItemFont_actionPerformed(ActionEvent arg0)
{
}
protected void menuItemFind_actionPerformed(ActionEvent arg0)
{
}
protected void menuItemSave_actionPerformed(ActionEvent arg0)
{
}
protected void menuItemScrollLock_actionPerformed(ActionEvent arg0)
{
}
protected void menuItemAbout_actionPerformed(ActionEvent arg0)
{
}
protected void menuItemClear_actionPerformed(ActionEvent arg0)
{
}
protected void menuItemSelectAll_actionPerformed(ActionEvent arg0)
{
}
protected void menuItemCopy_actionPerformed(ActionEvent arg0)
{
}
protected void menuItemCreateConnect_actionPerformed(
ActionEvent arg0)
{
}
protected void menuItemStart_actionPerformed(ActionEvent e)
{
}
protected void menuItemStop_actionPerformed(ActionEvent e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -