?? myframe1.java
字號:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class myframe1 extends JFrame implements ActionListener {
int width = 400;
int len =330;
JLabel jiashu = new JLabel("請輸入您要添加節(jié)點: ");
JLabel jiashu1= new JLabel();
JLabel jiashu2= new JLabel();
JLabel jiashu3= new JLabel();
JLabel jiashu4= new JLabel();
JTextField into = new JTextField(15);
JTextField into1 = new JTextField(15);
JTextField into2 = new JTextField(15);
JTextField into3 = new JTextField(15);
JTextField into4 = new JTextField(15);
JPanel jia = new JPanel();
JPanel jia1 = new JPanel();
JPanel jia2 = new JPanel();
JButton button3 = new JButton("確定");
JButton button4 =new JButton("繼續(xù)添加");
public myframe1()
{
JFrame myframe =new JFrame("添加節(jié)點對話框");
Container content1 = getContentPane();
myframe.setLayout(new BorderLayout());
WindowDestroyer myListener1 = new WindowDestroyer();
addWindowListener(myListener1);
myframe.setSize(width,len-100);
content1.setBackground(Color.RED);
into.setBackground(Color.YELLOW);
jia.add(jiashu);
jia.add(into);
jia.setBackground(Color.magenta);
myframe.add(jia,BorderLayout.NORTH);//該對話框的上部已做完
//int a= Integer.parseInt(into.getText());
jiashu1.setText("請輸入您添加節(jié)點的前驅(qū):");
into1.setBackground(Color.YELLOW);
into3.setBackground(Color.YELLOW);
into4.setBackground(Color.YELLOW);
jia1.add(jiashu1);
jia1.add(into1);
jia1.setBackground(Color.magenta);
jiashu3.setText("加入節(jié)點與前驅(qū)節(jié)點的權(quán)值");
jia1.add(jiashu3);
jia1.add(into3);
jiashu2.setText("請輸入您添加節(jié)點的后繼:");
into2.setBackground(Color.YELLOW);
jia1.add(jiashu2);
jia1.add(into2);
jiashu4.setText("加入節(jié)點與后繼節(jié)點的權(quán)值");
jia1.add(jiashu4);
jia1.add(into4);
myframe.add(jia1,BorderLayout.CENTER);//該對話框的中部已做完
button3.setBackground(Color.green);
button4.setBackground(Color.green);
jia2.add(button3);
button3.addActionListener(this);
button4.addActionListener(this);
jia2.add(button4);
myframe.add(jia2,BorderLayout.SOUTH);//該對話框的中部已做完
myframe.setVisible(true);
}
AWD Path1=new AWD (10,100000000);
String place[] = new String[10];
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("確定"))
{
for(int i=1;i<=5;i++)
{
place[i]=new String();
}
place[1]="a";
place[2]="b";
place[3]="c";
place[4]="d";
place[5]="e";
Path1.Add(1, 2, 1);
Path1.Add(2, 3, 1);
Path1.Add(1, 3, 4);
int m= Integer.parseInt(into1.getText()) ;
int M= Integer.parseInt(into3.getText()) ;
Path1.Add(5, m, M);
int n= Integer.parseInt(into2.getText()) ;
int N= Integer.parseInt(into4.getText()) ;
Path1.Add(5, n, N);
GUI gui = new GUI();
}
if(e.getActionCommand().equals("繼續(xù)添加"))
{
myframe1 frame1 = new myframe1();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -