Initial revision

This commit is contained in:
dchandler 2003-07-05 22:13:17 +00:00
parent 8c4ab30a52
commit 0643096899
139 changed files with 10024 additions and 0 deletions

View file

@ -0,0 +1,26 @@
import java.net.*;
import java.awt.*;
import javax.swing.*;
import calpa.html.*;
public class MyFifthCalPaneApplication {
public static void main(String args[]) {
String markup = "<H1>Hello World</H1><P align=center><OBJECT type=jcomponent jname=mycolorchooser>";
//create ColorChooser, name it, add it to CalHTMLManager
JColorChooser chooser = new JColorChooser();
chooser.setName("mycolorchooser");
CalHTMLManager.addUserComponent(chooser);
JFrame f = new JFrame();
CalHTMLPane pane = new CalHTMLPane();
f.getContentPane().add(pane, "Center");
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
f.setSize(new Dimension(Math.min(d.width - 10, 800), Math.min(d.height - 40, 600)));
f.setVisible(true);
pane.showHTMLDocument(markup);
}
}

View file

@ -0,0 +1,31 @@
import java.net.*;
import java.awt.*;
import javax.swing.*;
import calpa.html.*;
public class MyFirstCalPaneApplication {
public static void main(String args[]) {
URL url = null;
try {
//This is an example URL. You need to format your own.
//If you use an http URL you'll need an open http connection
url = new URL("file:///c:/jdk1.2/docs/api/overview-summary.html");
} catch (MalformedURLException e) {
System.err.println("Malformed URL");
System.exit(1);
}
JFrame f = new JFrame();
CalHTMLPane pane = new CalHTMLPane();
f.getContentPane().add(pane, "Center");
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
f.setSize(new Dimension(Math.min(d.width - 10, 800), Math.min(d.height - 40, 600)));
f.setVisible(true);
if (url != null) {
pane.showHTMLDocument(url);
pane.requestFocus();
}
}
}

View file

@ -0,0 +1,50 @@
import java.net.*;
import java.awt.*;
import javax.swing.*;
import calpa.html.*;
public class MyFourthCalPaneApplication {
public static void main(String args[]) {
URL url = null;
try {
url = new URL("file:///c:/jdk1.2/docs/api/overview-summary.html");
} catch (MalformedURLException e) {
System.err.println("Malformed URL");
System.exit(1);
}
JFrame f = new JFrame();
JLabel label = new JLabel("0");
label.setBorder(BorderFactory.createEmptyBorder(2, 8, 2, 8));
label.setPreferredSize(label.getPreferredSize());
label.setText("");
CalHTMLPane pane = new CalHTMLPane(null, new MyCalHTMLObserver(label), null);
f.getContentPane().add(pane, "Center");
f.getContentPane().add(label, "South");
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
f.setSize(new Dimension(Math.min(d.width - 10, 800), Math.min(d.height - 40, 600)));
f.setVisible(true);
if (url != null) {
pane.showHTMLDocument(url);
}
}
private static class MyCalHTMLObserver extends DefaultCalHTMLObserver {
JLabel label;
public MyCalHTMLObserver(JLabel label) {
super();
this.label = label;
}
public void linkFocusedUpdate(CalHTMLPane p, URL url) {
label.setText((url == null) ? "" : url.toExternalForm());
}
}
}

View file

@ -0,0 +1,36 @@
import java.net.*;
import java.awt.*;
import javax.swing.*;
import calpa.html.*;
public class MySecondCalPaneApplication {
public static void main(String args[]) {
URL url = null;
try {
url = new URL("file:///c:/jdk1.2/docs/api/overview-summary.html");
} catch (MalformedURLException e) {
System.err.println("Malformed URL");
System.exit(1);
}
JFrame f = new JFrame();
//create a Preferences object
CalHTMLPreferences pref = new CalHTMLPreferences();
//use one of its methods to enable the test navbar
pref.setShowTestNavBar(true);
//now pass the pref object to the Pane's constructor
CalHTMLPane pane = new CalHTMLPane(pref, null, null);
f.getContentPane().add(pane, "Center");
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
f.setSize(new Dimension(Math.min(d.width - 10, 800), Math.min(d.height - 40, 600)));
f.setVisible(true);
if (url != null) {
pane.showHTMLDocument(url);
}
}
}

View file

@ -0,0 +1,48 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import calpa.html.*;
public class MySixthCalPaneApplication {
public static void main(String args[]) {
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
d.width = Math.min(d.width, 800);
d.height = Math.min(d.height, 600);
JFrame f = new JFrame();
CalHTMLPane pane = new CalHTMLPane();
JPanel p = new JPanel();
JTextArea ta = new JTextArea();
ta.setLineWrap(true);
JScrollPane sp = new JScrollPane(ta);
sp.setPreferredSize(new Dimension(d.width / 2, d.height / 4));
JButton b = new JButton("Show Dialog");
b.addActionListener(new MyListener(pane, ta));
p.add(sp);
p.add(b);
f.getContentPane().add(pane, "Center");
f.getContentPane().add(p, "South");
f.setSize(new Dimension(d.width - 10, d.height - 40));
f.setVisible(true);
}
private static class MyListener implements ActionListener {
CalHTMLPane pane;
JTextArea ta;
public MyListener(CalHTMLPane pane, JTextArea ta) {
this.pane = pane;
this.ta = ta;
}
public void actionPerformed(ActionEvent e) {
pane.showDialog(ta.getText(), null, -1, -1, -1, -1);
}
}
}

View file

@ -0,0 +1,68 @@
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import calpa.html.*;
public class MyThirdCalPaneApplication {
public static void main(String args[]) {
URL url = null;
try {
url = new URL("file:///c:/jdk1.2/docs/api/overview-summary.html");
} catch (MalformedURLException e) {
System.err.println("Malformed URL");
System.exit(1);
}
JFrame f = new JFrame();
CalHTMLPane pane = new CalHTMLPane();
f.getContentPane().add(pane, "Center");
//create a panel, add buttons, and add a listener to the buttons
JPanel p = new JPanel();
MyListener ml = new MyListener(pane);
String[] s = {"Reload", "Back", "Forward", "Stop"};
JButton b;
for (int i=0; i<4; i++) {
b = new JButton(s[i]);
b.addActionListener(ml);
p.add(b);
}
f.getContentPane().add(p, "South");
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
f.setSize(new Dimension(Math.min(d.width - 10, 800), Math.min(d.height - 40, 600)));
f.setVisible(true);
if (url != null) {
pane.showHTMLDocument(url);
}
}
private static class MyListener implements ActionListener {
CalHTMLPane pane;
public MyListener(CalHTMLPane pane) {
this.pane = pane;
}
public void actionPerformed(ActionEvent e) {
String s = e.getActionCommand();
if (("Reload").equals(s)) {
pane.reloadDocument();
} else if (("Back").equals(s)) {
pane.goBack();
} else if (("Forward").equals(s)) {
pane.goForward();
} else if (("Stop").equals(s)) {
pane.stopAll();
}
}
}
}