/*
* MainFrame.java - HelpGui main frame
* Copyright (C) 2003 Alexandre THOMAS
* [email protected]
* http://helpgui.sourceforge.net
*
* 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 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 net.sourceforge.helpgui.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolBar;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import net.sourceforge.helpgui.page.PageBookMarks;
import net.sourceforge.helpgui.util.Language;
import net.sourceforge.helpgui.parser.TocOpen;
import net.sourceforge.helpgui.util.Out;
import net.sourceforge.helpgui.HelpGui;
/**
* Main frame of the help GUI
* @author Alexandre THOMAS
*/
public class MainFrame extends JFrame implements ActionListener{
/** Version of HelpGUI.*/
public String version = "1.0";
/**Buttons on the toolbar*/
protected JButton jbPrev;
protected JButton jbNext;
protected JButton jbHome;
protected JButton jbPrint;
protected JButton jbBookmarks;
/** Menu for bookmarks */
JMenu menuBookMarks;
//The view of the data
protected HelpView helpView;
/** The help path where the data are */
public static String helpPath = "/docs/help";
/** The icons path where the icons are */
public static String iconsPath = "java";
////////////////////////////////////////////////////////////////////
/** Standard Constructor. */
public MainFrame () {
super("Help Gui");
initFrame("/docs/help", iconsPath);
}
/** Standard Constructor. */
public MainFrame (String helpPath) {
super("Help Gui");
initFrame(helpPath, iconsPath);
}
/** Standard Constructor. */
public MainFrame(String helpPath, String iconsPath) {
super("Help Gui");
initFrame(helpPath, iconsPath);
}
/** Standard Constructor. */
public void initFrame(String helpPath, String iconsPath) {
//Remove the last "/" character
if(helpPath.endsWith("/")) helpPath = helpPath.substring(0,helpPath.length()-1);
this.helpPath = helpPath;
this.iconsPath = iconsPath;
//Default action on close
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
setVisible(false);
}
});
//Create the menu bar
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
JMenu menuFile = new JMenu(Language.getInstance().getText("file"));
JMenu menuAction = new JMenu(Language.getInstance().getText("action"));
menuBookMarks = new JMenu(Language.getInstance().getText("bookmarks"));
menuBar.add(menuFile);
menuBar.add(menuAction);
menuBar.add(menuBookMarks);
menuFile.add(Language.getInstance().getText("print")).addActionListener(this);
menuFile.add(Language.getInstance().getText("quit")).addActionListener(this);
menuAction.add(Language.getInstance().getText("previous")).addActionListener(this);
menuAction.add(Language.getInstance().getText("next")).addActionListener(this);
menuAction.add(Language.getInstance().getText("home")).addActionListener(this);
menuBookMarks.add(Language.getInstance().getText("addBookmarks")).addActionListener(this);
menuBookMarks.addSeparator();
//Construct the buttons
jbPrev = new TestRolloverButton(new ImageIcon(getClass().getResource("/net/sourceforge/helpgui/icons/"+iconsPath+"/previous.gif")));
jbNext = new TestRolloverButton(new ImageIcon(getClass().getResource("/net/sourceforge/helpgui/icons/"+iconsPath+"/next.gif")));
jbHome = new TestRolloverButton(new ImageIcon(getClass().getResource("/net/sourceforge/helpgui/icons/"+iconsPath+"/home.gif")));
jbPrint = new TestRolloverButton(new ImageIcon(getClass().getResource("/net/sourceforge/helpgui/icons/"+iconsPath+"/print.gif")));
jbBookmarks = new TestRolloverButton(new ImageIcon(getClass().getResource("/net/sourceforge/helpgui/icons/"+iconsPath+"/addbookmarks.gif")));
jbPrev.addActionListener(this);
jbNext.addActionListener(this);
jbHome.addActionListener(this);
jbPrint.addActionListener(this);
jbBookmarks.addActionListener(this);
//Construct a toolbar
JToolBar toolBar = new JToolBar();
toolBar.setRollover(true);
toolBar.setFloatable(false);
toolBar.setBorderPainted(true);
//Add buttons to toolbar
toolBar.add(jbPrev);
toolBar.add(jbNext);
toolBar.add(jbHome);
toolBar.add(jbPrint);
toolBar.add(jbBookmarks);
//Set ToolTipsText to the button
jbPrev.setToolTipText(Language.getInstance().getText("previous"));
jbNext.setToolTipText(Language.getInstance().getText("next"));
jbHome.setToolTipText(Language.getInstance().getText("home"));
jbPrint.setToolTipText(Language.getInstance().getText("print"));
jbBookmarks.setToolTipText(Language.getInstance().getText("addBookmarks"));
//View of Data
helpView = new HelpView();
//Construct gui parameters
GridBagLayout gbPanel = new GridBagLayout();
GridBagConstraints gbcPanel = new GridBagConstraints();
getContentPane().setLayout( gbPanel );
//Add the main tool bar
gbcPanel.gridx = 0;
gbcPanel.gridy = 0;
gbcPanel.gridwidth = 1;
gbcPanel.gridheight = 1;
gbcPanel.fill = GridBagConstraints.VERTICAL;
gbcPanel.weightx = 1;
gbcPanel.weighty = 0;
gbcPanel.anchor = GridBagConstraints.WEST;
gbPanel.setConstraints( toolBar, gbcPanel );
getContentPane().add( toolBar );
//Add the panel with data to the mainframe
gbcPanel.gridx = 0;
gbcPanel.gridy = 1;
gbcPanel.gridwidth = 1;
gbcPanel.gridheight = 1;
gbcPanel.fill = GridBagConstraints.BOTH;
gbcPanel.weightx = 1;
gbcPanel.weighty = 1;
gbcPanel.anchor = GridBagConstraints.CENTER;
gbPanel.setConstraints( helpView, gbcPanel );
getContentPane().add( helpView );
//Pack the window
pack();
setLocation(100,100);
//Set a message
Out.msg("Construction of the GUI", Out.OK);
//Load the TOC
try {
TocOpen opener = new TocOpen (helpView);
opener.load();
Out.msg("Loading the Table of Content", Out.OK);
} catch (Exception e) {
Out.msg("Table of Content XML parsing", Out.FAILED);
System.out.println(e);
}
//Go to the home page
helpView.goHome();
//helpView.firstNodeExpand();
}
/** Handles buttons events */
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof JButton) {
if(e.getSource().equals(jbPrev))
helpView.previousPage();
else if(e.getSource().equals(jbNext))
helpView.nextPage();
else if(e.getSource().equals(jbHome))
helpView.goHome();
else if(e.getSource().equals(jbPrint))
helpView.print();
else if(e.getSource().equals(jbBookmarks))
addBookMarks();
} else if (e.getSource() instanceof JMenuItem) {
String arg = e.getActionCommand();
if (arg.equals(Language.getInstance().getText("previous")))
helpView.previousPage();
else if (arg.equals(Language.getInstance().getText("next")))
helpView.nextPage();
else if (arg.equals(Language.getInstance().getText("home")))
helpView.goHome();
else if (arg.equals(Language.getInstance().getText("print")))
helpView.print();
else if (arg.equals(Language.getInstance().getText("quit")))
quit(
没有合适的资源?快使用搜索试试~ 我知道了~
JAVA帮助视图组件库 Help GUI 1.1源代码.zip
共133个文件
gif:80个
java:17个
png:11个
需积分: 0 0 下载量 137 浏览量
2022-08-28
10:39:35
上传
评论
收藏 168KB ZIP 举报
温馨提示
JAVA帮助视图组件库 Help GUI 1.1源代码.zip
资源推荐
资源详情
资源评论
收起资源包目录
JAVA帮助视图组件库 Help GUI 1.1源代码.zip (133个子文件)
COPYING 18KB
style.css 1KB
print.gif 1KB
home.gif 1KB
next.gif 1KB
addbookmarks.gif 1KB
previous.gif 1KB
print.gif 1KB
home.gif 1KB
print.gif 1KB
home.gif 1KB
next.gif 1KB
print.gif 1KB
previous.gif 1KB
contents.gif 1KB
sheet.gif 1KB
addbookmarks.gif 1023B
print.gif 1018B
home.gif 1016B
home.gif 1004B
addbookmarks.gif 998B
addbookmarks.gif 970B
addbookmarks.gif 748B
contents.gif 733B
home.gif 721B
print.gif 700B
home.gif 681B
addbookmarks.gif 660B
contents2.gif 642B
contents2.gif 642B
sheet.gif 609B
previous.gif 608B
addbookmarks.gif 606B
next.gif 588B
contents2.gif 586B
contents2.gif 586B
sheet.gif 582B
print.gif 581B
contents.gif 572B
contents.gif 570B
contents.gif 570B
contents2.gif 555B
sheet.gif 532B
print.gif 499B
home.gif 491B
addbookmarks.gif 446B
next.gif 434B
previous.gif 422B
contents.gif 384B
sheet.gif 384B
next.gif 374B
addbookmarks.gif 369B
previous.gif 364B
previous.gif 357B
next.gif 355B
sheet.gif 350B
sheet.gif 350B
home.gif 343B
contents2.gif 341B
addbookmarks.gif 283B
print.gif 227B
home.gif 221B
previous.gif 209B
next.gif 207B
next.gif 182B
previous.gif 179B
sheet.gif 175B
contents.gif 173B
contents.gif 169B
contents.gif 165B
contents2.gif 156B
sheet.gif 152B
contents2.gif 148B
contents2.gif 143B
next.gif 138B
sheet.gif 133B
print.gif 120B
contents.gif 118B
contents2.gif 114B
previous.gif 108B
previous.gif 77B
next.gif 76B
icons.html 2KB
toc.html 1KB
license.html 1KB
features.html 1KB
contacts.html 830B
introduction.html 829B
launch.html 828B
dirweb.html 823B
MainFrame.java 8KB
HelpView.java 8KB
Page.java 6KB
BrowserControl.java 6KB
PageRoot.java 4KB
XMLParser.java 3KB
PageList.java 3KB
TestRolloverButton.java 2KB
TocOpen.java 2KB
TextArea.java 2KB
共 133 条
- 1
- 2
资源评论
「已注销」
- 粉丝: 119
- 资源: 213
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功