?? mainframe.java
字號:
package fi.javasom.gui;
/**
* Main frame for the Clusoe GUI.
*
* Copyright (C) 2001 Tomi Suuronen
*
* @version 1.0
*
* 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
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import fi.javasom.gui.*;
public class MainFrame extends JFrame implements ActionListener
{
private JMenuBar menuBar;
private JMenu helpMenu;
private JMenu editMenu;
private JMenuItem aboutItem;
private JMenuItem clearItem;
private JMenuItem pdfItem;
private AboutDialog aboutDialog;
private Dimension screenSize;
private MainPanel mainPanel;
/*
* Creates MenuBar.
*/
private void makeMenuBar()
{
menuBar = new JMenuBar();
helpMenu = new JMenu("Help");
editMenu = new JMenu("Edit");
aboutItem = new JMenuItem("About");
clearItem = new JMenuItem("Clear fields");
pdfItem = new JMenuItem("PDF settings");
clearItem.addActionListener(this);
aboutItem.addActionListener(this);
pdfItem.addActionListener(this);
helpMenu.add(aboutItem);
editMenu.add(clearItem);
editMenu.add(pdfItem);
menuBar.add(editMenu);
menuBar.add(helpMenu);
}
/*
* Performs actions.
*/
public void actionPerformed(ActionEvent ev)
{
Object source = ev.getSource();
//about item action
if (source == aboutItem)
{
if(aboutDialog == null)
{
aboutDialog = new AboutDialog(this,screenSize);
}
aboutDialog.show();
}
//clear all fields action
if(source == clearItem)
{
mainPanel.clearAllFields();
}
//save item action
if(source == pdfItem)
{
mainPanel.activatePdfSettings();
}
}
/*
* Constructor for MainFrame.
*/
public MainFrame()
{
int width = 510, height = 600;
setTitle("Clusoe");
setSize(width,height);
setResizable(false);
Toolkit tk = Toolkit.getDefaultToolkit();
screenSize = tk.getScreenSize();
setLocation((screenSize.width-width)/2,(screenSize.height-height)/2);
Image img = tk.getImage("logo.gif");
setIconImage(img);
//adds a windows listener
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
//adds the menubar
makeMenuBar();
setJMenuBar(menuBar);
// add the main panel
mainPanel = new MainPanel(this,screenSize);
Container contentPane = getContentPane();
contentPane.add(mainPanel);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -