📄 dialogdalete.java
字号:
package net.aetherial.gis.surface.editTrackPoint;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import net.aetherial.gis.surface.ItemValue;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.Vector;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class DialogDalete
extends JDialog {
JPanel panel1 = new JPanel();
JScrollPane jScrollPane1 = new JScrollPane();
JTable table = new JTable(new TableModel());
JButton jButtonSubmit = new JButton();
FlowLayout flowLayout1 = new FlowLayout();
JButton jButtonCancel = new JButton();
int tracks = -1;
public DialogDalete(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
pack();
}
catch (Exception exception) {
exception.printStackTrace();
}
}
public DialogDalete() {
this(new Frame(), "DialogDalete", false);
}
public DialogDalete(int tracksPos) {
this();
//table = null;
this.tracks = tracksPos;
table = new JTable(new TableModel(tracksPos));
//table.repaint();
jScrollPane1.getViewport().add(table);
}
private void init(){
Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
this.setTitle("编辑航迹点");
this.setSize(800,500);
this.setLocation(
(screenDim.width - 800) / 2,
(screenDim.height - 500) / 2
);
}
private void jbInit() throws Exception {
this.init();
panel1.setLayout(flowLayout1);
jButtonSubmit.setText("确定");
jButtonSubmit.addActionListener(new
DialogDalete_jButton_actionAdapter(this));
jButtonSubmit.setActionCommand("submit");
jButtonCancel.setText("取消");
jButtonCancel.addActionListener(new
DialogDalete_jButton_actionAdapter(this));
jButtonCancel.setActionCommand("cancel");
this.getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
jScrollPane1.getViewport().add(table);
this.getContentPane().add(panel1, java.awt.BorderLayout.SOUTH);
panel1.add(jButtonSubmit, null);
panel1.add(jButtonCancel);
}
public static void main(String args[]){
DialogDalete d = new DialogDalete();
d.setTitle("test table");
d.setSize(500,500);
d.show();
}
private void getValue(){
int row = this.table.getRowCount();
int column = this.table.getColumnCount();
for(int i = 0;i<row;i++){
for(int j = 0;j<column;j++){
System.out.println("("+i+","+j+"):"+this.table.getValueAt(i,j));
}
}
}
private void deletePoint(){
Node node = ItemValue.getTracksByPos(this.tracks);
NodeList nl = ItemValue.getTracksPoint(node);
Vector v = new Vector();
for(int i =0;i<nl.getLength() ;i++){
if (((Boolean)(this.table.getValueAt(i,5))).booleanValue()){
v.add(nl.item(i));
}
}
for(int i =0;i<v.size() ;i++){
ItemValue.deleteTracksPoint(node,(Node)(v.get(i)));
}
}
private boolean haveDeletePoint(){
boolean have = false;
int row = this.table.getRowCount();
for(int i =0;i<row;i++){
if (((Boolean)(this.table.getValueAt(i,5))).booleanValue()){
have = true;
}
}
return have;
}
private void showMSG(){
if(!(this.haveDeletePoint())){
this.hide();
}else{
int value = JOptionPane.showConfirmDialog(this, "删除选中的航迹点吗?", "确认删除",
JOptionPane.YES_NO_OPTION);
if (value == 0) {
this.deletePoint();
this.hide();
}
}
}
public void jButton_actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("submit")){
this.showMSG();
}else if(e.getActionCommand().equals("cancel")){
this.hide();
}
}
}
class DialogDalete_jButton_actionAdapter
implements ActionListener {
private DialogDalete adaptee;
DialogDalete_jButton_actionAdapter(DialogDalete adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -