⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialogdeletewaypoint.java

📁 基于Java的地图数据管理软件。使用MySQL数据库管理系统。
💻 JAVA
字号:
package net.aetherial.gis.surface;

import java.awt.*;
import javax.swing.*;
import net.aetherial.gis.surface.ItemValue;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.w3c.dom.Node;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class DialogDeleteWaypoint
    extends JDialog {
  JPanel panel1 = new JPanel();
  BorderLayout borderLayout1 = new BorderLayout();
  JScrollPane jScrollPane1 = new JScrollPane();
  JPanel jPanel1 = new JPanel();
  XYLayout xYLayout1 = new XYLayout();
  JButton jButtonSubmit = new JButton();
  JButton jButtonCancel = new JButton();
  JCheckBox[] jWaypointCheckBox = null;
  private FrameMain fm = null;
  public DialogDeleteWaypoint(Frame owner, String title, boolean modal) {
    super(owner, title, modal);
    try {
      setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      jbInit();
      pack();
    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
  }

  public DialogDeleteWaypoint(FrameMain fm) {
    this(fm, "DialogDeleteWaypoint", false);
    this.fm = fm;
  }

  private void jbInit() throws Exception {

    panel1.setLayout(borderLayout1);
    jPanel1.setLayout(xYLayout1);
    addWaypoint();
    jButtonSubmit.setText("确定");
    jButtonSubmit.addActionListener(new
        DialogDeleteWaypoint_jButtonSubmit_actionAdapter(this));
    jButtonCancel.setText("取消");
    jButtonCancel.addActionListener(new
        DialogDeleteWaypoint_jButtonCancel_actionAdapter(this));
    getContentPane().add(panel1);
    panel1.add(jScrollPane1, java.awt.BorderLayout.CENTER);
    jScrollPane1.getViewport().add(jPanel1);
    jPanel1.add(jButtonSubmit, new XYConstraints(94, 12, -1, -1));
    jPanel1.add(jButtonCancel, new XYConstraints(218, 12, -1, -1));
  }

  private void addWaypoint(){
    final int height = 30;
    final int width =150;
    int y =0;

    int[] pos = ItemValue.getPosition("waypoint");
    if (pos == null) {
      return;
    }
    jWaypointCheckBox = new JCheckBox[pos.length];
    if(pos.length>0){
      for (int i= 0;i<pos.length;i++){
        if((i % 3) == 0 ){
          y++;
        }
        jWaypointCheckBox[i] = new JCheckBox();
        jWaypointCheckBox[i].setText("[" +(i+1) + "]" + ItemValue.getWaypointName(pos[i]));
        jPanel1.add(jWaypointCheckBox[i], new XYConstraints((20+width*(i % 3)), (30+y*height), -1, -1));
        //jWaypointCheckBox.addItemListener(new DialogInsertTracks_jCheckBox_itemAdapter(this));
        //jWaypointCheckBox.setActionCommand(i+"");
        //jWaypointCheckBox = null;
      }
    }
  }
  private boolean[] getSelect(){
    boolean[] delete = new boolean[this.jWaypointCheckBox.length];
    if(delete == null){
      return null;
    }
    for(int i = 0;i<delete.length;i++){
      delete[i] = this.jWaypointCheckBox[i].isSelected();
    }
    return delete;
  }
  private void deleteWaypoint(){
    boolean[] select = this.getSelect();
    Node[] allWpts = ItemValue.getWaypoint();
    for(int i =0;i<allWpts.length;i++){
      if(select[i]){
        ItemValue.removeWaypoint(allWpts[i]);
      }
    }
  }

  public void jButtonSubmit_actionPerformed(ActionEvent e) {
    int i = JOptionPane.showConfirmDialog(this,"确实要删除选择的航点吗?","删除航点",JOptionPane.OK_CANCEL_OPTION);
    if(i == 0){
      this.deleteWaypoint();
      this.fm.memoryShow(false,true);
      this.hide();
    }
  }

  public void jButtonCancel_actionPerformed(ActionEvent e) {
    this.hide();
  }
}

class DialogDeleteWaypoint_jButtonCancel_actionAdapter
    implements ActionListener {
  private DialogDeleteWaypoint adaptee;
  DialogDeleteWaypoint_jButtonCancel_actionAdapter(DialogDeleteWaypoint adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.jButtonCancel_actionPerformed(e);
  }
}

class DialogDeleteWaypoint_jButtonSubmit_actionAdapter
    implements ActionListener {
  private DialogDeleteWaypoint adaptee;
  DialogDeleteWaypoint_jButtonSubmit_actionAdapter(DialogDeleteWaypoint adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.jButtonSubmit_actionPerformed(e);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -