summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2006-12-06 21:02:18 +0000
committerRoman Kennke <roman@kennke.org>2006-12-06 21:02:18 +0000
commit0e19f288ecc715fd85a0395fd313005130e30d06 (patch)
tree68d5d1d18da631a77f5869103844e6f99a601c54
parent5e741748dd0b54d0523d6f53602c706fc679f700 (diff)
downloadclasspath-0e19f288ecc715fd85a0395fd313005130e30d06.tar.gz
2006-12-06 Roman Kennke <kennke@aicas.com>
* examples/gnu/classpath/examples/icons/back.png, * examples/gnu/classpath/examples/icons/reload.png: New icons for the HTML browser. * examples/gnu/classpath/examples/swing/HtmlDemo.java (history): New field. Manages the browsing history. (HtmlDemo): Initialize history. (createContent): Set location and add history. Add toolbar. (createToolBar): New helper method. (main): Make default size bigger. * examples/gnu/classpath/examples/swing/frame1.html, * examples/gnu/classpath/examples/swing/frame2.html, * examples/gnu/classpath/examples/swing/frame3.html, * examples/gnu/classpath/examples/swing/frame4.html, * examples/gnu/classpath/examples/swing/frames.html, * examples/gnu/classpath/examples/swing/tables.html: New example pages. * examples/gnu/classpath/examples/swing/welcome.html Add a couple of links and new test pages.
-rw-r--r--ChangeLog21
-rw-r--r--examples/gnu/classpath/examples/icons/back.pngbin0 -> 828 bytes
-rw-r--r--examples/gnu/classpath/examples/icons/reload.pngbin0 -> 1324 bytes
-rw-r--r--examples/gnu/classpath/examples/swing/HtmlDemo.java99
-rw-r--r--examples/gnu/classpath/examples/swing/frame1.html41
-rw-r--r--examples/gnu/classpath/examples/swing/frame2.html42
-rw-r--r--examples/gnu/classpath/examples/swing/frame3.html42
-rw-r--r--examples/gnu/classpath/examples/swing/frame4.html41
-rw-r--r--examples/gnu/classpath/examples/swing/frames.html44
-rw-r--r--examples/gnu/classpath/examples/swing/tables.html66
10 files changed, 387 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index beeb9264a..767e0b3d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
2006-12-06 Roman Kennke <kennke@aicas.com>
+ * examples/gnu/classpath/examples/icons/back.png,
+ * examples/gnu/classpath/examples/icons/reload.png:
+ New icons for the HTML browser.
+ * examples/gnu/classpath/examples/swing/HtmlDemo.java
+ (history): New field. Manages the browsing history.
+ (HtmlDemo): Initialize history.
+ (createContent): Set location and add history. Add toolbar.
+ (createToolBar): New helper method.
+ (main): Make default size bigger.
+ * examples/gnu/classpath/examples/swing/frame1.html,
+ * examples/gnu/classpath/examples/swing/frame2.html,
+ * examples/gnu/classpath/examples/swing/frame3.html,
+ * examples/gnu/classpath/examples/swing/frame4.html,
+ * examples/gnu/classpath/examples/swing/frames.html,
+ * examples/gnu/classpath/examples/swing/tables.html:
+ New example pages.
+ * examples/gnu/classpath/examples/swing/welcome.html
+ Add a couple of links and new test pages.
+
+2006-12-06 Roman Kennke <kennke@aicas.com>
+
* javax/swing/JEditorPane.java
(getStream): Buffer the stream for efficiency.
(setPage): Don't scroll the view at this point.
diff --git a/examples/gnu/classpath/examples/icons/back.png b/examples/gnu/classpath/examples/icons/back.png
new file mode 100644
index 000000000..d320f26c6
--- /dev/null
+++ b/examples/gnu/classpath/examples/icons/back.png
Binary files differ
diff --git a/examples/gnu/classpath/examples/icons/reload.png b/examples/gnu/classpath/examples/icons/reload.png
new file mode 100644
index 000000000..04c575002
--- /dev/null
+++ b/examples/gnu/classpath/examples/icons/reload.png
Binary files differ
diff --git a/examples/gnu/classpath/examples/swing/HtmlDemo.java b/examples/gnu/classpath/examples/swing/HtmlDemo.java
index 4cbf3ce47..527670fee 100644
--- a/examples/gnu/classpath/examples/swing/HtmlDemo.java
+++ b/examples/gnu/classpath/examples/swing/HtmlDemo.java
@@ -44,8 +44,10 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URL;
+import java.util.LinkedList;
import javax.swing.BoxLayout;
+import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
@@ -53,6 +55,7 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
+import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
@@ -98,10 +101,17 @@ public class HtmlDemo extends JPanel
int n;
+ /**
+ * The browsing history.
+ *
+ * Package private to avoid accessor method.
+ */
+ LinkedList history;
+
public HtmlDemo()
{
super();
- html.setContentType("text/html"); // not now.
+ history = new LinkedList();
createContent();
}
@@ -128,6 +138,8 @@ public class HtmlDemo extends JPanel
try
{
html.setPage(u);
+ url.setText(u.toString());
+ history.addLast(u);
}
catch (IOException ex)
{
@@ -148,24 +160,93 @@ public class HtmlDemo extends JPanel
JButton loadButton = new JButton("go");
urlPanel.add(loadButton);
loadButton.addActionListener(action);
- add(urlPanel, BorderLayout.NORTH);
- add(scroller, BorderLayout.CENTER);
+
+ // Setup control panel.
+ JToolBar controlPanel = createToolBar();
+ JPanel browserPanel = new JPanel();
+ browserPanel.setLayout(new BorderLayout());
+ browserPanel.add(urlPanel, BorderLayout.NORTH);
+ browserPanel.add(scroller, BorderLayout.CENTER);
+ add(controlPanel, BorderLayout.NORTH);
+ add(browserPanel, BorderLayout.CENTER);
// Load start page.
- URL startpage = getClass().getResource("welcome.html");
try
{
+ URL startpage = getClass().getResource("welcome.html");
html.setPage(startpage);
url.setText(startpage.toString());
+ history.addLast(startpage);
}
- catch (IOException ex)
+ catch (Exception ex)
{
- System.err.println("couldn't load page: " + startpage);
+ System.err.println("couldn't load page: "/* + startpage*/);
+ ex.printStackTrace();
}
-
- setPreferredSize(new Dimension(600, 400));
+ setPreferredSize(new Dimension(800, 600));
}
+
+ /**
+ * Creates the toolbar with the control buttons.
+ *
+ * @return the toolbar with the control buttons
+ */
+ JToolBar createToolBar()
+ {
+ JToolBar tb = new JToolBar();
+ Icon backIcon = Demo.getIcon("/gnu/classpath/examples/icons/back.png",
+ "back");
+ JButton back = new JButton(backIcon);
+ back.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ if (history.size() > 1)
+ {
+ URL last = (URL) history.removeLast();
+ last = (URL) history.getLast();
+ url.setText(last.toString());
+ try
+ {
+ html.setPage(last);
+ }
+ catch (IOException ex)
+ {
+ // Do something more useful.
+ ex.printStackTrace();
+ }
+ }
+ }
+ });
+ tb.add(back);
+ Icon reloadIcon = Demo.getIcon("/gnu/classpath/examples/icons/reload.png",
+ "reload");
+ JButton reload = new JButton(reloadIcon);
+ reload.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ if (history.size() > 0)
+ {
+ URL last = (URL) history.getLast();
+ url.setText(last.toString());
+ try
+ {
+ html.setPage(last);
+ }
+ catch (IOException ex)
+ {
+ // Do something more useful.
+ ex.printStackTrace();
+ }
+ }
+ }
+ });
+ tb.add(reload);
+ return tb;
+ }
+
/**
* The executable method to display the editable table.
*
@@ -182,7 +263,7 @@ public class HtmlDemo extends JPanel
HtmlDemo demo = new HtmlDemo();
JFrame frame = new JFrame();
frame.getContentPane().add(demo);
- frame.setSize(new Dimension(700, 480));
+ frame.setSize(new Dimension(750, 480));
frame.setVisible(true);
}
});
diff --git a/examples/gnu/classpath/examples/swing/frame1.html b/examples/gnu/classpath/examples/swing/frame1.html
new file mode 100644
index 000000000..b9150592f
--- /dev/null
+++ b/examples/gnu/classpath/examples/swing/frame1.html
@@ -0,0 +1,41 @@
+<!-- frame1.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+<html>
+<body>
+<h1>Top Left Frame</h1>
+</body>
+</html>
diff --git a/examples/gnu/classpath/examples/swing/frame2.html b/examples/gnu/classpath/examples/swing/frame2.html
new file mode 100644
index 000000000..9dbf33c5a
--- /dev/null
+++ b/examples/gnu/classpath/examples/swing/frame2.html
@@ -0,0 +1,42 @@
+<!-- frame2.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+<html>
+<body>
+<h1>Top Right
+ Frame</h1>
+</body>
+</html>
diff --git a/examples/gnu/classpath/examples/swing/frame3.html b/examples/gnu/classpath/examples/swing/frame3.html
new file mode 100644
index 000000000..e677bd6a1
--- /dev/null
+++ b/examples/gnu/classpath/examples/swing/frame3.html
@@ -0,0 +1,42 @@
+<!-- frame3.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+<html>
+<body>
+<h1>Bottom Left Frame</h1>
+</body>
+</html>
+
diff --git a/examples/gnu/classpath/examples/swing/frame4.html b/examples/gnu/classpath/examples/swing/frame4.html
new file mode 100644
index 000000000..1da53b101
--- /dev/null
+++ b/examples/gnu/classpath/examples/swing/frame4.html
@@ -0,0 +1,41 @@
+<!-- frame4.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+<html>
+<body>
+<h1>Bottom Left Frame</h1>
+</body>
+</html>
diff --git a/examples/gnu/classpath/examples/swing/frames.html b/examples/gnu/classpath/examples/swing/frames.html
new file mode 100644
index 000000000..e7e2bf87c
--- /dev/null
+++ b/examples/gnu/classpath/examples/swing/frames.html
@@ -0,0 +1,44 @@
+<!-- frames.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+<html>
+<frameset cols="40%,60%" rows="20%,80%">
+ <frame src="frame1.html">
+ <frame src="frame2.html">
+ <frame src="frame3.html">
+ <frame src="frame4.html">
+</frameset>
+</html> \ No newline at end of file
diff --git a/examples/gnu/classpath/examples/swing/tables.html b/examples/gnu/classpath/examples/swing/tables.html
new file mode 100644
index 000000000..af908e1ab
--- /dev/null
+++ b/examples/gnu/classpath/examples/swing/tables.html
@@ -0,0 +1,66 @@
+<!-- tables.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+
+<head>
+ <title>HTML text styles</title>
+ </head>
+ <body>
+<h1>Table examples</h1>
+<h2>Table with grid and mixed rowspan/colspan</h2>
+ <table border="1">
+ <tr>
+ <td width="30%" colspan="2">Spans two columns</td>
+ <td rowspan="3">Spans three rows</td>
+ </tr>
+ <tr>
+ <td rowspan="2">Spans two rows</td>
+ <td>This is the center</td>
+ </tr>
+ <tr>
+ <td>This should be in the middle of row number 3</td>
+ </tr>
+ <tr>
+ <td>A small one cell box</td>
+ <td colspan="2" rowspan="2">Spans two x two cells</td>
+ </tr>
+ <tr>
+ <td>Another small one cell box</td>
+ </tr>
+ </table>
+</body></html>