Ik heb een class TNOlogo, die is naar mening goed --> compilen geeft geen fouten. Daaronder is een gedeelte van mijn GUI class. Die wel errors geeft.
Hieronder het gedeelte van mijn GUI class
Dit levert mij de volgende errors op:
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:175: illegal start of type
this.getContentPane().add(tnologo);
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:175: <identifier> expected
this.getContentPane().add(tnologo);
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:179: illegal start of type
this.getContentPane().add(canvas)
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:181: <identifier> expected
TNOLogo tnologo = new TNOLogo(575,423, "http://www.tno.nl/");
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:184: illegal start of type
this.getContentPane().add(tnologo);
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:184: <identifier> expected
this.getContentPane().add(tnologo);
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:187: illegal start of type
this.setVisible(true);
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:187: <identifier> expected
this.setVisible(true);
^
8 errors
Tool completed with exit code 1
Waar ga ik hier de mist in?
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
| /*
Tijmen Kuipers
Juni 2002 Project Blok 1.4
*/
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import java.net.*;
import java.io.IOException;
class TNOLogo extends JPanel implements MouseListener
{
private Image tnologo;
private static final String WIN_ID = "Windows";
private static final String WIN_PATH = "rundll32";
private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
private String imageUrl;
/*
===============
public TNOLogo(int x, int y, String imageUrl)
constructor, loads the images and sets the
panel, also registers the mouselistener
===============
*/
public TNOLogo(int x, int y, String imageUrl)
{
this.imageUrl = imageUrl;
URL url = ClassLoader.getSystemResource("buttons/but-tno.gif");
this.setBounds(x,y,100,100);
this.addMouseListener(this);
tnologo = Toolkit.getDefaultToolkit().getImage(url);
}
/*
===============
public void paintComponent(Graphics g)
paints the image on the screen
===============
*/
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.drawImage(tnologo, 0, 0, this);
}
/*
===============
MouseEvents
opens the link when clicked on the panel
throws an error if it can't open the
browser
===============
*/
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e)
{
String cmd = null;
try
{
cmd = WIN_PATH + " " + WIN_FLAG + " " + imageUrl;
Process p = Runtime.getRuntime().exec(cmd);
}
catch(IOException z)
{
System.err.println("Could not invoke browser, command=" + cmd);
System.err.println("Caught: " + z);
}
}
public void mouseReleased(MouseEvent e){}
public void mousePressed(MouseEvent e){}
} |
Hieronder het gedeelte van mijn GUI class
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| // ------------------------------------------
// Tijmen juni 2002 (get it working) begin
// ------------------------------------------
class TNOlogo extends JFrame
{
// deze zet het panel op het frame
this.getContentPane().add(tnologo);
// empty panel(swing) deez laat je items op je scherm arrangen
JPanel canvas = new JPanel();
this.getContentPane().add(canvas)
TNOLogo tnologo = new TNOLogo(575,423, "http://www.tno.nl/");
// add the panels to the frame
this.getContentPane().add(tnologo);
// and display it
this.setVisible(true);
} |
Dit levert mij de volgende errors op:
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:175: illegal start of type
this.getContentPane().add(tnologo);
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:175: <identifier> expected
this.getContentPane().add(tnologo);
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:179: illegal start of type
this.getContentPane().add(canvas)
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:181: <identifier> expected
TNOLogo tnologo = new TNOLogo(575,423, "http://www.tno.nl/");
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:184: illegal start of type
this.getContentPane().add(tnologo);
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:184: <identifier> expected
this.getContentPane().add(tnologo);
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:187: illegal start of type
this.setVisible(true);
^
C:\Documents and Settings\kuiperst\Desktop\Tijmen13juni\GUI.java:187: <identifier> expected
this.setVisible(true);
^
8 errors
Tool completed with exit code 1
Waar ga ik hier de mist in?