📄 welcomedialog.java
字号:
/* * YALE - Yet Another Learning Environment * Copyright (C) 2002, 2003 * Simon Fischer, Ralf Klinkenberg, Ingo Mierswa, * Katharina Morik, Oliver Ritthoff * Artificial Intelligence Unit * Computer Science Department * University of Dortmund * 44221 Dortmund, Germany * email: yale@ls8.cs.uni-dortmund.de * 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 javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JButton;import javax.swing.JPanel;import javax.swing.JRadioButton;import javax.swing.JList;import javax.swing.Box;import javax.swing.BoxLayout;import javax.swing.ButtonGroup;import javax.swing.BorderFactory;import javax.swing.border.BevelBorder;import javax.swing.event.ListSelectionListener;import javax.swing.event.ListSelectionEvent;import java.awt.BorderLayout;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;/** Lets the user select with what he wants to start: blank, existing file, recent file, or wizard. */public class WelcomeDialog extends JDialog { private static final int NEW = 0; private static final int RECENT = 1; private static final int OPEN = 2; private static final int WIZARD = 3; private JRadioButton[] startOptions = { new JRadioButton("Start with a blank experiment"), new JRadioButton("Open one of the recently used experiments"), new JRadioButton("Open an existing experiment"), new JRadioButton("Start the Experiment Wizard") }; private JList recentFileList; private ButtonGroup buttonGroup = new ButtonGroup(); private MainFrame mainFrame; public WelcomeDialog(MainFrame mainFrame) { super(mainFrame, "Welcome to YALE!", true); this.mainFrame = mainFrame; Box box = new Box(BoxLayout.Y_AXIS); box.setBorder(BorderFactory.createEmptyBorder(11,11,11,11)); for (int i = 0; i < startOptions.length; i++) { box.add(startOptions[i]); buttonGroup.add(startOptions[i]); startOptions[i].setAlignmentX(0.0f); if (i == RECENT) { if (YaleGUI.getRecentFiles().size() == 0) { startOptions[RECENT].setEnabled(false); } else { recentFileList = new JList(YaleGUI.getRecentFiles().toArray(new Object[YaleGUI.getRecentFiles().size()])); recentFileList.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); recentFileList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); recentFileList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { startOptions[RECENT].setSelected(true); } }); JPanel listPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); listPanel.add(recentFileList); listPanel.setBorder(BorderFactory.createEmptyBorder(0,30,0,0)); listPanel.setAlignmentX(0.0f); box.add(listPanel); startOptions[RECENT].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (recentFileList.getSelectedIndex() == -1) recentFileList.setSelectedIndex(0); } }); } } } startOptions[NEW].setSelected(true); getContentPane().add(box, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton start = new JButton("Start"); start.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { start(); } }); buttonPanel.add(start); getContentPane().add(buttonPanel, BorderLayout.SOUTH); setResizable(false); pack(); setLocationRelativeTo(mainFrame); } private void start() { dispose(); int selected = 0; while (!startOptions[selected].isSelected()) selected++; switch (selected) { case NEW: break; case OPEN: mainFrame.open(); break; case RECENT: mainFrame.open((File)YaleGUI.getRecentFiles().get(recentFileList.getSelectedIndex())); break; case WIZARD: new WizardDialog(mainFrame).show(); break; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -