Yo - im making an animation which draws a string to a panel and moves it once the class is loaded. This all works fine but I want to change the colour of the string to white, the background will be black by the way, as well as make it bold and italic.

I've tried using HTML tags, which work on the other strings i have created. I also tried using a JLabel, which works but I can't draw a component using:

Graphics2D g2d = (Graphics2D) g;
		g2d.drawString( text, textX, textY );

g2d doesn't contain a draw component option. So what are my options?

Also how do I specify a components position, I used the setBounds() method as well as the setLocation() method, neither worked. Does it matter that it was within a JPanel?

Cheers

You can use those methods to set your component locations if you set your layout to null. If you move the component, you won't need to use the graphics methods.

If you want to use the graphics methods instead, you could make a small banner component that paints the moving text across the black background and use setFont() and setColor() to stylize the text.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.