📄 uiarcinfo.java
字号:
/*
* @(#) UIArcInfo.java 1.10 10/09/02
*
* Copyright ***, All Rights Reserved.
*
* This software is the proprietary information of ********
* Use is subject to license terms.
*
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import java.io.*;
import java.lang.*;
import java.util.*;
import javax.swing.table.*;
/**
* This class is to .....
* .....
* .....
* @version 1.00
* @author Kaihua Huang
*/
public class UIArcInfo extends JDialog implements ActionListener {
//-----------------------------------------------------------------
//
// static data members
//
//-----------------------------------------------------------------
//-----------------------------------------------------------------
//
// instance data members
//
//-----------------------------------------------------------------
// data in two lists, user can set it from outside of the class
//
public GraphArc arc_d = null;
JPanel jMainPane = new JPanel();
JPanel jBottomPane = new JPanel();
GridBagLayout gridBagLayout1 = new GridBagLayout();
JPanel jTopPane = new JPanel();
JLabel jLabelWeight = new JLabel("Weight");
JTextField jTextFieldWeight = new JTextField();
JCheckBox jCheckBoxEpsilon = new JCheckBox();
JButton jButtonOK = new JButton();
JButton jButtonCancel = new JButton();
//-----------------------------------------------------------------
//
// function members
//
//-----------------------------------------------------------------
public UIArcInfo(Frame frame, String title, boolean modal,
GraphArc arc_a) {
super(frame, title, modal);
setArc(arc_a);
initAll();
}
public UIArcInfo() {
}
/**
* init everything for a dialog
*
* @return void
*/
public void initAll(){
try {
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
void jbInit() throws Exception {
// set the main pane
//
jMainPane.setLayout(gridBagLayout1);
jMainPane.setPreferredSize(new Dimension(320, 100));
getContentPane().add(jMainPane);
// add three panes on the main pane
//
jMainPane.add(jTopPane,
new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(0, 0, 5, 0), 0, 0));
jMainPane.add(jBottomPane,
new GridBagConstraints(0, 1, 1, 1, 1.0, 0,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(5, 0, 10, 0), 0, 0));
// add components on the top pane
//
jTopPane.add(jLabelWeight);
jTopPane.add(jTextFieldWeight);
//jTopPane.add(jLableEpsilon);
jTopPane.add(jCheckBoxEpsilon);
jTopPane.setLayout(new FlowLayout());
jTextFieldWeight.setPreferredSize(new Dimension(80, 24));
jTextFieldWeight.setText(arc_d.weights_d);
jLabelWeight.setText("Arc Weight");
jCheckBoxEpsilon.setText("Epsilon Transision");
jLabelWeight.setBounds(new Rectangle(16, 9, 41, 17));
if ( arc_d.epsilon_d ){
jCheckBoxEpsilon.setSelected(true);
}
else {
jCheckBoxEpsilon.setSelected(false);
}
// add components for the bottom pane
//
jBottomPane.setLayout(new FlowLayout(FlowLayout.CENTER));
jButtonOK.setText("OK");
jButtonCancel.setText("Cancel");
jButtonOK.setPreferredSize(new Dimension(80, 24));
jButtonCancel.setPreferredSize(new Dimension(80, 24));
jButtonOK.addActionListener(this);
jButtonCancel.addActionListener(this);
jBottomPane.add(jButtonOK);
jBottomPane.add(jButtonCancel);
}
/**
* set corresponding vertex for this dialog
*
* @param GraphArc the Arc
* @return void
*/
public void setArc(GraphArc arc_a) {
arc_d = arc_a;
}
/**
* handle the event when a button is clicked
*
* @param e the button event
* @return void
*/
public void actionPerformed(ActionEvent e) {
// decide which button is clicked
//
if(e.getSource() == jButtonOK) {
arc_d.weights_d = jTextFieldWeight.getText();
arc_d.epsilon_d = jCheckBoxEpsilon.isSelected();
dispose();
}
if(e.getSource() == jButtonCancel) {
dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -