D:\javahelp-2_0_01\demos\bin>java -jar hsviewer.jar
〈?xml version="1.0" encoding="euc-kr" ?〉
〈!DOCTYPE helpset
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 1.0//EN"
"http://java.sun.com/products/javahelp/helpset_1_0.dtd"〉
〈helpset version="1.0" xml:lang="kr"〉
〈!-- title --〉
〈title〉한빛미디어〈/title〉
〈!-- maps --〉
〈maps〉
〈!--기본으로 지정될 타겟의 ID--〉
〈homeID〉overview〈/homeID〉
〈mapref location="Map.jhm"/〉
〈/maps〉
〈view〉
〈name〉TOC〈/name〉
〈label〉Table Of Contents〈/label〉
〈type〉javax.help.TOCView〈/type〉
〈data〉TOC.xml〈/data〉
〈/view〉
〈view〉
〈name〉Index〈/name〉
〈label〉Index〈/label〉
〈type〉javax.help.IndexView〈/type〉
〈data〉Index.xml〈/data〉
〈/view〉
〈/helpset〉
〈?xml version="1.0" encoding="euc-kr" ?〉
〈!DOCTYPE index
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Index Version 1.0//EN"
"http://java.sun.com/products/javahelp/index_1_0.dtd"〉
〈index version="1.0"〉
〈indexitem text="C++" target="c++"/〉
〈indexitem text="데이터베이스" target="database" /〉
〈indexitem text="오라클" target="database" /〉
〈indexitem text="자바" target="java"/〉
〈indexitem text="JSP" target="java"/〉
〈/index〉
〈?xml version="1.0" encoding="euc-kr" ?〉
〈!DOCTYPE map
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN"
"http://java.sun.com/products/javahelp/map_1_0.dtd"〉
〈map version="1.0"〉
〈mapID target="overview" url="topics/overview.html" /〉
〈mapID target="java" url="topics/java/java.html" /〉
〈mapID target="c++" url="topics/c++/c++.html" /〉
〈mapID target="database" url="topics/database/database.html" /〉
〈/map〉
〈?xml version="1.0" encoding="euc-kr" ?〉
〈!DOCTYPE toc
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 1.0//EN"
"http://java.sun.com/products/javahelp/toc_1_0.dtd"〉
〈toc version="1.0"〉
〈tocitem text="한빛미디어"〉
〈tocitem text="소개" target="overview"/〉
〈tocitem text="Java" target="java"/〉
〈tocitem text="C++" target="c++"/〉
〈tocitem text="Database" target="database"/〉
〈/tocitem〉
〈/toc〉
D:\javahelp\demos\bin>java -jar hsviewer.jar -helpset D:\javahelp-2_0_01\my_sample\HelpSet.hs
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import javax.help.*;
import javax.swing.event.*;
public class HanbitHelp extends JFrame {
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu();
JMenu editMenu = new JMenu();
JMenu helpMenu = new JMenu();
JMenuItem exitItem = new JMenuItem();
JMenuItem helpItem = new JMenuItem();
HelpSet helpSet;
HelpBroker helpBroker;
BorderLayout borderLayout1 = new BorderLayout();
JTabbedPane tabbedPane = new JTabbedPane();
JPanel javaPanel = new JPanel();
JPanel cppPanel = new JPanel();
JPanel dbPanel = new JPanel();
public HanbitHelp() {
try {
jbInit();
setSize(500, 300);
setVisible(true);
}
catch (Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setJMenuBar(menuBar);
this.setTitle("JavaHelp");
this.getContentPane().setLayout(borderLayout1);
fileMenu.setText("File");
editMenu.setText("Edit");
helpMenu.setText("Help");
exitItem.setText("Exit");
helpItem.setText("Contents");
menuBar.add(fileMenu);
menuBar.add(editMenu);
menuBar.add(helpMenu);
fileMenu.add(exitItem);
helpMenu.add(helpItem);
this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
tabbedPane.add(javaPanel, "Java");
tabbedPane.add(cppPanel, "C++");
tabbedPane.add(dbPanel, "Database");
initHelp();
helpItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new CSH.DisplayHelpFromSource(helpBroker);
// 반드시 true로 호출해야만 보인다
helpBroker.setDisplayed(true);
}
});
exitItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
tabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(ChangeEvent e) {
tabbedPane_stateChanged(e);
}
});
}
private void initHelp() {
try {
// 헬프셋 파일을 지정한다
File file = new File("D:\\javahelp-2_0_01\\my_sample\\HelpSet.hs");
URL hsURL = file.toURL();
helpSet = new HelpSet(null, hsURL);
}
catch (Exception ex) {
ex.printStackTrace();
System.out.println("Cannot find helpset file");
}
helpBroker = helpSet.createHelpBroker();
helpBroker.setSize(new Dimension(500, 500));
// 기본값 id를 지정
helpBroker.enableHelpKey(getRootPane(), "overview", helpSet);
}
// 선택된 탭의 위치에 따라 다른 도움말 내용이 변하도록 처리
void tabbedPane_stateChanged(ChangeEvent e) {
JTabbedPane comp = (JTabbedPane) e.getSource();
int index = comp.getSelectedIndex();
if (index == 0) {
// 맵 파일에 정의된 id를 설정한다
helpBroker.setCurrentID("java");
}
else if (index == 1) {
helpBroker.setCurrentID("c++");
}
else {
helpBroker.setCurrentID("database");
}
}
public static void main(String[] args) {
HanbitHelp help = new HanbitHelp();
}
}
최신 콘텐츠