⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainframe.java

📁 Kohonen网络的学习过程可描述为:对于每一个网络的输入
💻 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 + -