📄 delinfowindow.java
字号:
package src;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class delInfoWindow extends JDialog{
private JLabel l1 = null;
private JLabel l2 = null;
private JTextField t1 = null;
private JTextField t2 = null;
private JButton b1 = null;
private JButton b2 = null;
private Graph g;
private cityFile file;
public delInfoWindow(JFrame f){
super(f,"",true);
setLayout(null);
g = new Graph();
file = new cityFile();
file.inputfromInfoFile(g);
l1 = new JLabel("输入删除起始城市名:");
t1 = new JTextField(10);
l2 = new JLabel("输入删除终点城市名:");
t2 = new JTextField(10);
b1 = new JButton("确定");
b2 = new JButton ("取消");
l1.reshape(20,30,150,20);
t1.reshape(150,30,110,20);
l2.reshape(20,65,150,20);
t2.reshape(150,65,110,20);
b1.reshape(60,110,65,25);
b2.reshape(160,110,65,25);
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
b1.addActionListener(new
ActionListener(){
public void actionPerformed(ActionEvent event){
if(t1.getText().equals("")||t2.getText().equals("")){
JOptionPane.showMessageDialog(null,"城 市 信 息 不 能 为 空 !!");
t1.grabFocus();
}
else{
int from = g.changetoNum(t1.getText());
int to = g.changetoNum(t2.getText());
if(from<0 || to<0)
JOptionPane.showMessageDialog(null,"城 市 信 息 不 存 在 !!");
else
{
int result = JOptionPane.showConfirmDialog(null,t1.getText()+" 与 "+t2.getText()+
"相关信息将完全删除?","",JOptionPane.OK_OPTION);
if(result == JOptionPane.OK_OPTION)
{
if(g.deletEdge(from,to))
{
JOptionPane.showMessageDialog(null,"删 除 成 功 !!");
file.outputtoInfoFile(g.records);
}
else
JOptionPane.showMessageDialog(null,"城 市 信 息 不 存 在 !!");
}
}
}
}
});
add(b2);
b2.addActionListener(new
ActionListener(){
public void actionPerformed(ActionEvent event){
setVisible(false);
}
});
setTitle("删除城市信息");
setSize(300,200);
setResizable(false);
setLocation(370,280);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -