📄 dialoginserttracks.java
字号:
package net.aetherial.gis.surface;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import org.w3c.dom.Node;
public class DialogInsertTracks extends JDialog {
JPanel panel1 = new JPanel();
JScrollPane jScrollPane1 = new JScrollPane();
JLabel jLabel1 = new JLabel();
JTextField jTextField1 = new JTextField();
JPanel jPanel1 = new JPanel();
XYLayout xYLayout1 = new XYLayout();
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel2 = new JPanel();
BorderLayout borderLayout2 = new BorderLayout();
String TracksID="";
JButton jButton1 = new JButton();
JLabel jLabel2 = new JLabel();
JCheckBox[] jWptArray = null;
Node[] wpt = ItemValue.getWaypoint();
public DialogInsertTracks(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public DialogInsertTracks() {
this(null, "", false);
}
public DialogInsertTracks(FrameMain fm) {
this(null, "", false);
this.TracksID = ItemValue.getTracksID(ItemValue.getTracksByPos(fm.tracksPos));
addWaypoint();
this.setSize(500,500);
}
public void addWaypoint(){
final int height = 30;
final int width =160;
int y =0;
if(wpt != null){
this.jWptArray = new JCheckBox[wpt.length];
for (int i= 0;i<wpt.length;i++){
if((i % 3) == 0 ){
y++;
}
this.jWptArray[i] = new JCheckBox();
this.jWptArray[i].setText("[" +(i+1) + "]" + ItemValue.getWaypointName(wpt[i]));
jPanel1.add(this.jWptArray[i], new XYConstraints((20+width*(i % 3)), (30+y*height), -1, -1));
// this.jWptArray[i].addItemListener(new DialogInsertTracks_jCheckBox_itemAdapter(this));
// this.jWptArray[i].setActionCommand(i+"");
if(ItemValue.getWaypointTracksID(wpt[i]).equals(this.TracksID)){
this.jWptArray[i].setSelected(true);
}
}
}
}
private void jbInit() throws Exception {
Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(
(screenDim.width - 500) / 2,
(screenDim.height - 500) / 2
);
this.setTitle("请选择航点");
this.addWindowFocusListener(new DialogToFront_this_windowFocusAdapter(this));
jLabel1.setText("航 迹 名 称:");
this.setModal(false);
panel1.setOpaque(true);
panel1.setLayout(borderLayout1);
jTextField1.setText("jTextField1");
jPanel1.setLayout(xYLayout1);
jPanel2.setLayout(borderLayout2);
jButton1.setText("确定");
jButton1.addActionListener(new DialogInsertTracks_jButton1_actionAdapter(this));
jLabel2.setText("请选择该航迹包含的航点:");
getContentPane().add(panel1, BorderLayout.CENTER);
panel1.add(jPanel2, BorderLayout.CENTER);
jPanel2.add(jScrollPane1, BorderLayout.CENTER);
jScrollPane1.getViewport().add(jPanel1, null);
jPanel1.add(jButton1, new XYConstraints(299, 10, 75, 22));
jPanel1.add(jLabel1, new XYConstraints(17, 13, -1, -1));
jPanel1.add(jTextField1, new XYConstraints(82, 10, 148, -1));
jPanel1.add(jLabel2, new XYConstraints(17, 37, 255, -1));
this.jTextField1.setEnabled(false);
}
void jCheckBox_itemStateChanged(ItemEvent e) {
// int pos = Integer.parseInt(((JCheckBox)e.getSource()).getActionCommand());
// //System.out.println("stateChage::"+e.getStateChange()+",ID:"+e.getID()+",source:"+((JCheckBox)e.getSource()).getActionCommand());
// if(e.getStateChange()==1){
// ItemValue.setWaypointTracksID(ItemValue.getWaypointByWaypointPos(pos),
// this.TracksID);
// }else{
// ItemValue.setWaypointTracksID(ItemValue.getWaypointByWaypointPos(pos),
// "");
// }
//e.getSource();
}
void jButton1_actionPerformed(ActionEvent e) {
String temp = "";
if (this.jWptArray != null) {
for (int i = 0; i < this.jWptArray.length; i++) {
if (this.jWptArray[i].isSelected()) {
ItemValue.setWaypointTracksID(wpt[i],this.TracksID);
}else{
temp = ItemValue.getWaypointTracksID(wpt[i]);
if (temp.equals(this.TracksID)) {
ItemValue.setWaypointTracksID(wpt[i],"-2");
}
}
}
}
this.hide();
}
}
class DialogInsertTracks_jCheckBox_itemAdapter implements java.awt.event.ItemListener {
DialogInsertTracks adaptee;
DialogInsertTracks_jCheckBox_itemAdapter(DialogInsertTracks adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.jCheckBox_itemStateChanged(e);
}
public static void main(String args[]){
DialogInsertTracks dit = new DialogInsertTracks();
dit.show();
}
}
class DialogInsertTracks_jButton1_actionAdapter implements java.awt.event.ActionListener {
DialogInsertTracks adaptee;
DialogInsertTracks_jButton1_actionAdapter(DialogInsertTracks adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -