📄 selectpanel.java
字号:
package net.aetherial.gis.our.auto.deal;
import javax.swing.JPanel;
import javax.swing.JFrame;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import net.aetherial.gis.surface.ItemValue;
import javax.swing.JFileChooser;
import java.io.File;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class SelectPanel extends JPanel{
private JFrame source = null;
public SelectPanel() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
SelectPanel selectpanel = new SelectPanel();
}
public void setJFrame(JFrame frame){
this.source = frame;
}
private void jbInit() throws Exception {
this.setLayout(xYLayout1);
jLabel1.setText("输入路径:");
jLabel2.setText("输出路径:");
jB_Input.setText("选择输入");
jB_Input.addActionListener(new SelectPanel_jB_actionAdapter(this));
jB_Output.setText("选择输出");
jB_Output.addActionListener(new SelectPanel_jB_actionAdapter(this));
this.add(jT_In, new XYConstraints(86, 11, 193, -1));
this.add(jLabel1, new XYConstraints(24, 15, -1, -1));
this.add(jLabel2, new XYConstraints(24, 52, -1, -1));
this.add(jT_Out, new XYConstraints(86, 51, 193, -1));
this.add(jB_Input, new XYConstraints(291, 12, -1, -1));
this.add(jB_Output, new XYConstraints(290, 52, -1, -1));
}
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField jT_In = new JTextField();
JTextField jT_Out = new JTextField();
JButton jB_Input = new JButton();
JButton jB_Output = new JButton();
public void jB_actionPerformed(ActionEvent e) {
if (e.getSource().equals(this.jB_Input)) {
this.selectPath(this.jT_In);
}
else if (e.getSource().equals(this.jB_Output)) {
this.selectPath(this.jT_Out);
}
}
public String getInputPath(){
String temp = this.jT_In.getText().trim();
if ((temp.endsWith("\\"))||(temp.endsWith("/"))) {
return temp;
}else{
return temp + "\\";
}
}
public String getOutputPath(){
String temp = this.jT_Out.getText().trim();
if ((temp.endsWith("\\"))||(temp.endsWith("/"))) {
return temp;
}else{
return temp + "\\";
}
}
private void selectPath(JTextField jText){
JFileChooser fileDialog = new JFileChooser();
fileDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if(!(ItemValue.fileChoosePath.equals(""))){
fileDialog.setCurrentDirectory(new File(ItemValue.fileChoosePath));
}
//fileDialog.setSelectedFile(new File(ItemValue.fileName));
int result = fileDialog.showOpenDialog(this.source);
if (result == JFileChooser.APPROVE_OPTION) {
File f = fileDialog.getSelectedFile();
ItemValue.fileChoosePath = f.getAbsolutePath();
jText.setText(f.getAbsolutePath());
}
}
}
class SelectPanel_jB_actionAdapter
implements ActionListener {
private SelectPanel adaptee;
SelectPanel_jB_actionAdapter(SelectPanel adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jB_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -