<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
<small><font face="Helvetica, Arial, sans-serif">Dear Colleagues,<br>
<br>
I'm a bloody java beginner and got an installation/configuration
problem. I downloaded and installed sun's jdk1.5.0_06 to my FC3 box in
/usr/share/jdk1.5.0_06/. I fiddled around with the symlinks to point to
the binaries in .../bin/ and javac etc. now run. However, I get a <br>
</font></small><font face="Courier New, Courier, monospace"><small><br>
java.lang.ClassCastException: SwingUI</small><br>
<small> at
sun.applet.AppletPanel.createApplet(AppletPanel.java:721)</small><br>
<small> at sun.applet.AppletPanel.runLoader(AppletPanel.java:650)</small><br>
<small> at sun.applet.AppletPanel.run(AppletPanel.java:324)</small><br>
<small> at java.lang.Thread.run(Thread.java:595)</small></font><br>
<small><font face="Helvetica, Arial, sans-serif"><br>
when I try to view the class built from the simple code at the end of
this message with appletviewer (all of the code there for completeness).</font></small><font
face="Helvetica, Arial, sans-serif"><small> I do think java doesn't
find javax.* - and don't know how to tell it where it is. I've set my <br>
<font face="Courier New, Courier, monospace"><br>
JAVA_HOME=/usr/share/jdk1.5.0_06/</font><br>
<br>
(that's where my installation is).<br>
<br>
Any idea what is going wrong here? (I posted a similar question to the
parallel sun-list, but got no solution from there...)<br>
<br>
THX, Peter<br>
<br>
Code:<br>
</small></font><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace">import java.awt.Color;</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace">import java.awt.BorderLayout;</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace">import java.awt.event.*;</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace">import javax.swing.*;</font></font></small><br>
<br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> public class SwingUI extends
JFrame</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> implements
ActionListener {</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> JLabel text, clicked;</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> JButton button, clickButton;</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> JPanel panel;</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> private boolean _clickMeMode
= true;</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> public void init() {</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace">
System.out.println("starting...");</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> }</font></font></small><br>
<br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> public SwingUI(){ //Begin
Constructor</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> text = new JLabel("I'm a
Simple Program");</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> button = new
JButton("Click Me");</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace">
button.addActionListener(this);</font></font></small><br>
<br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> panel = new JPanel();</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> panel.setLayout(new
BorderLayout());</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace">
panel.setBackground(Color.white);</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace">
getContentPane().add(panel);</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace">
panel.add(BorderLayout.CENTER, text);</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace">
panel.add(BorderLayout.SOUTH, button);</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> } //End Constructor</font></font></small><br>
<br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> public void
actionPerformed(ActionEvent event){</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> Object source =
event.getSource();</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> if (_clickMeMode) {</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> text.setText("Button
Clicked");</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> button.setText("Click
Again");</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> _clickMeMode = false;</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> } else {</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> text.setText("I'm a
Simple Program");</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> button.setText("Click
Me");</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> _clickMeMode = true;</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> }</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> }</font></font></small><br>
<br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> public static void
main(String[] args){</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> SwingUI frame = new
SwingUI();</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> frame.setTitle("Example");</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> _clickMeMode = false;</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> } else {</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> text.setText("I'm a
Simple Program");</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> button.setText("Click
Me");</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> _clickMeMode = true;</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> }</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> }</font></font></small><br>
<br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> public static void
main(String[] args){</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> SwingUI frame = new
SwingUI();</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> frame.setTitle("Example");</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> WindowListener l = new
WindowAdapter() {</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> public void
windowClosing(WindowEvent e) {</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> System.exit(0);</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> }</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> };</font></font></small><br>
<br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> frame.addWindowListener(l);</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> frame.pack();</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> frame.setVisible(true);</font></font></small><br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace"> }</font></font></small><br>
<br>
<small><font face="Helvetica, Arial, sans-serif"><font
face="Courier New, Courier, monospace">}</font></font></small><br>
<font face="Helvetica, Arial, sans-serif"><small><br>
</small></font><small></small>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.peter-kuehnlein.net">http://www.peter-kuehnlein.net</a>
"The Way of the Samurai is in desperateness. Ten men or more cannot
kill such a man."
(Hagakure)
Upcoming event:
<a class="moz-txt-link-freetext" href="http://www.constraints-in-discourse.org/cid06">http://www.constraints-in-discourse.org/cid06</a>
</pre>
</body>
</html>