📄 connectconfigdialog.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.]
*
* ---------------
* ConnectConfigDialog.java
* ---------------
* (C) Copyright 2006-2006, by yang zhongke
*
* Original Author: yang zhongke;
*
* Changes
* -------
*
*/
package com.cownew.JDBMonitor.listenerImpl.sckListenerClient;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.util.prefs.Preferences;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import com.cownew.JDBMonitor.listenerImpl.uicommon.JCownewDialog;
import com.cownew.JDBMonitor.listenerImpl.uicommon.JIntTextField;
public class ConnectConfigDialog extends JCownewDialog
{
private static final String PORT = "port";
private static final String HOST_NAME = "hostName";
private static final long serialVersionUID = -4080991388689423528L;
protected JTextField txtHostName;
protected JIntTextField txtPort;
public ConnectConfigDialog(Frame parentFrame) throws HeadlessException
{
super(parentFrame,true);
container.setLayout(new GridLayout(3,2));
}
protected void initUI()
{
super.initUI();
JLabel labelHostName = new JLabel();
labelHostName.setText("host name or address:");
container.add(labelHostName);
txtHostName = new JTextField();
labelHostName.setLabelFor(txtHostName);
container.add(txtHostName);
JLabel labelPort = new JLabel();
labelPort.setText("port:");
container.add(labelPort);
txtPort = new JIntTextField();
labelPort.setLabelFor(txtPort);
container.add(txtPort);
container.add(createOKBtn());
container.add(createCancelBtn());
}
protected boolean verifyData()
{
if(txtHostName.getText().trim().length()<=0)
{
JOptionPane.showMessageDialog(this,"HostName cannot be null!");
return false;
}
String port = txtPort.getText().trim();
if(port.length()<=0)
{
JOptionPane.showMessageDialog(this,"Port cannot be null!");
return false;
}
return super.verifyData();
}
protected void saveConfig()
{
Preferences prefer = Preferences.userNodeForPackage(getClass());
prefer.put(HOST_NAME,getHostName());
prefer.putInt(PORT,getPort());
}
protected void loadConfig()
{
Preferences prefer = Preferences.userNodeForPackage(getClass());
setHostName(prefer.get(HOST_NAME,""));
setPort(prefer.getInt(PORT,9527));
}
public void setHostName(String value)
{
txtHostName.setText(value);
}
public String getHostName()
{
return txtHostName.getText();
}
public void setPort(int port)
{
txtPort.setText(new Integer(port).toString());
}
public int getPort()
{
return txtPort.getInt();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -