📄 settingsdialog.java
字号:
/*
* YALE - Yet Another Learning Environment
* Copyright (C) 2001-2004
* Simon Fischer, Ralf Klinkenberg, Ingo Mierswa,
* Katharina Morik, Oliver Ritthoff
* Artificial Intelligence Unit
* Computer Science Department
* University of Dortmund
* 44221 Dortmund, Germany
* email: yale-team@lists.sourceforge.net
* web: http://yale.cs.uni-dortmund.de/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*/
package edu.udo.cs.yale.gui;
import edu.udo.cs.yale.tools.ParameterService;
import javax.swing.JDialog;
import javax.swing.JTextArea;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.IOException;
public class SettingsDialog extends JDialog {
private SettingsPropertyTable table = new SettingsPropertyTable();
public SettingsDialog(JFrame owner) {
super(owner, "Settings", true);
BorderLayout borderLayout = new BorderLayout();
borderLayout.setHgap(5);
borderLayout.setVgap(5);
JPanel panel = new JPanel(borderLayout);
JTextArea label = new JTextArea("You can edit the file '"+ParameterService.getConfigFile("yalerc")+"' to make system wide settings. This dialog will save all changes to '"+ParameterService.getUserConfigFile("yalerc" + "." + System.getProperty("os.name"))+"'.", 3, 60);
label.setLineWrap(true);
label.setWrapStyleWord(true);
label.setBackground(this.getBackground());
label.setEditable(false);
panel.add(label, BorderLayout.NORTH);
panel.add(new JScrollPane(table), BorderLayout.CENTER);
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JButton ok = new JButton("Apply");
ok.setToolTipText("Apply settings for this session.");
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
table.applyProperties();
dispose();
}
});
buttonPanel.add(ok);
JButton save = new JButton("Save");
save.setToolTipText("Save settings for this and future sessions.");
save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
table.save();
dispose();
} catch (IOException ioe) {
SwingTools.showSimpleErrorMessage("Cannot save properties.", ioe);
}
}
});
buttonPanel.add(save);
JButton cancel = new JButton("Cancel");
cancel.setToolTipText("Do not change settings.");
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
buttonPanel.add(cancel);
panel.add(buttonPanel, BorderLayout.SOUTH);
panel.setBorder(javax.swing.BorderFactory.createEmptyBorder(11,11,11,11));
getContentPane().add(panel);
pack();
setLocationRelativeTo(owner);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -