📄 addcityinfowindow.java
字号:
package src;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class addCityInfoWindow extends JDialog{
private Graph g;
private cityFile file;
public addCityInfoWindow(JFrame f) {
super(f,"添加城市信息",true);
g = new Graph();
file = new cityFile();
file.inputfromInfoFile(g);
setLayout(null);
l = new JLabel("城市名:");
l.reshape(30,30,60,20);
t = new JTextField(10);
t.reshape(80,30,100,20);
b1 = new JButton("确定");
b1.reshape(35,80,65,20);
b1.addActionListener(new
ActionListener(){
public void actionPerformed(ActionEvent event){
if(t.getText().equals("")){
JOptionPane.showMessageDialog(null,"城 市 名 不 能 为 空!!");
t.grabFocus();
}
else{
//int c = g.changetoNum(t.getText());
//if(c>=0)
// JOptionPane.showMessageDialog(null,"城 市 已 存 在!!");
//else
//{
if(g.insertCity(t.getText()))
{
JOptionPane.showMessageDialog(null,"城 市 添 加 成 功!!");
file.outtoNameFile(g.citylist,g.cityNum);
}
else
JOptionPane.showMessageDialog(null,"城 市 存 满/也存在 !!");
//}
}
}
});
b2 = new JButton("取消");
b2.reshape(120,80,65,20);
b2.addActionListener(new
ActionListener(){
public void actionPerformed(ActionEvent event){
setVisible(false);
}
});
add(l);
add(t);
add(b1);
add(b2);
setSize(230,160);
setLocation(400,200);
}
private JLabel l;
private JTextField t;
private JButton b1;
private JButton b2;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -