📄 configdialog.java
字号:
/*
* Created on 2004-6-1
*/
package yuchifang.javaIDE.dialog;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JTextField;
import yuchifang.javaIDE.JavaIDE;
/**
* @author yuchifang
*/
public class ConfigDialog extends JDialog
{
private final static int WIDTH = 400; //对话框宽度
private final static int HEIGHT = 200; //对话框高度
private JButton openFolder;
private JButton ok;
private JButton temp = new JButton(" ");
private JButton cancel;
private JTextField editPath;
private JavaIDE parent;
public ConfigDialog(final JavaIDE parent)
{
setTitle("Please the JDK Home Folder");
setSize(WIDTH, HEIGHT);
ok = new JButton("OK");
cancel = new JButton("Cancel");
openFolder = new JButton("...");
editPath = new JTextField();
editPath.setText(parent.getJDKPath());
//set layout
GridBagLayout gbl = new GridBagLayout();
setLayout(gbl);
add(editPath, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
add(openFolder, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
JPanel p = new JPanel();
p.add(ok);
p.add(temp);
temp.setVisible(false);
p.add(cancel);
add(p, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
this.parent = parent;
ok.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String jdkPath = editPath.getText();
if (!jdkPath.endsWith("\\") && !jdkPath.endsWith("/"))
{
jdkPath = jdkPath + "\\";
}
parent.setJDKPath(jdkPath);
setVisible(false);
}
}
);
cancel.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
setVisible(false);
}
}
);
openFolder.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setSelectedFile(new File(parent.getJDKPath() == null ? "" : parent.getJDKPath()));
// fc.setSelectedFile(new File(parent.getJDKPath()));
fc.showOpenDialog(ConfigDialog.this);
editPath.setText(fc.getSelectedFile().getPath());
}
});
}
//##添加些什么呢,应该从config.xml文件读入的
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -