|
Ive created an applet in java for which displays images on a canvas, it also has panels for the buttons and components. I have used the paint method for displaying the images. The problem I'm haveing is that when I run the applet the panels are painted over, such that only the buttons are visible but the panels borders are just painted over.
|
|
|
i had the same problem.
firstly you must create another canvas in where all the graphics would be drawn onto.
Then add this new canvas just like you would add a button to the applet
i.e. add(CanvasName);
|
|
|
By painting on the canvas part of the problem is solved but the other panels and the menubar are still painted over.
|
|
|
/b Example what to to
import java.awt.*;
class can extends Canvas
{
public void paint (Graphics g)
{
g.setColor(Color.blue);
g.setFont (new Font ("Arial", Font.PLAIN, 12));
g.drawString("Hello AK_47", 20, 50);
}
}
public class Loading extends Frame
{
Button b1 = new Button("hello");
public Loading () throws Exception
{
super ("EG"); // Set the frame's name
setLayout(new GridLayout(1,2));
add(b1);
add(new can());
setSize (200, 200);
show();
}
public static void main (String [] args) throws Exception
{
new Loading ();
}
}
<Added>
Example what to to
import java.awt.*;
class can extends Canvas
{
public void paint (Graphics g)
{
g.setColor(Color.blue);
g.setFont (new Font ("Arial", Font.PLAIN, 12));
g.drawString("Hello AK_47", 20, 50);
}
}
public class Loading extends Frame
{
Button b1 = new Button("hello");
public Loading () throws Exception
{
super ("EG"); // Set the frame's name
setLayout(new GridLayout(1,2));
add(b1);
add(new can());
setSize (200, 200);
show();
}
public static void main (String [] args) throws Exception
{
new Loading ();
}
}
|
|
|
|
|
|
|
|