Results 1 to 4 of 4
Thread: JApplet drawing printing
- 10-12-2011, 12:55 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 59
- Rep Power
- 0
JApplet drawing printing
Hi everybody.........
I have a problem with my program. And I need ur help.........
now I want to print the drawing objects over the CanvasPrint2 class through my printer.Java Code:package freeHandDrawJappletInternalFrame; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class PrintApplet2 extends JApplet implements ActionListener { Graphics2D g2; CanvasPrint2 fdc; @Override public void init(){ this.setLayout(new BorderLayout()); JPanel panel = new JPanel(); this.add(panel); Button print = new Button("Print"); print.addActionListener(this); fdc = new CanvasPrint2(); panel.add(fdc,BorderLayout.NORTH); panel.add(print,BorderLayout.SOUTH); } @Override public void actionPerformed(ActionEvent e) { } } class CanvasPrint2 extends Canvas { public CanvasPrint2() { setSize(200, 200); setBackground(Color.yellow); } @Override public void paint(Graphics g) { //CanvasPrint1(){ Graphics2D g2 = (Graphics2D) g; //Graphics2D g2 = null; g2.setColor(Color.blue); g2.drawLine(30, 30, 80, 80); g2.drawRect(20, 150, 100, 100); g2.fillRect(20, 150, 100, 200); g2.fillOval(150, 20, 100, 100); } }
Not the whole applet, just the area specified by the CanvasPrint2 () constructor.
And how can I do it?
Please help......
ThanksLast edited by mitra; 10-12-2011 at 01:31 PM.
- 10-12-2011, 02:48 PM #2
Re: JApplet drawing printing
Can't you just draw it to a BufferedImage, and then print that out?
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 10-13-2011, 06:31 AM #3
Member
- Join Date
- Jun 2011
- Posts
- 59
- Rep Power
- 0
- 10-13-2011, 09:10 AM #4
Member
- Join Date
- Jun 2011
- Posts
- 59
- Rep Power
- 0
Similar Threads
-
Help with printing an arrayList. printing the first element twice
By kingkongjaffa in forum New To JavaReplies: 9Last Post: 08-19-2011, 12:59 AM -
JApplet only drawing 1/5 of my app and then greying out
By CrashWave in forum Java AppletsReplies: 2Last Post: 04-09-2011, 09:12 PM -
printing string backwards and printing every other
By droidus in forum New To JavaReplies: 22Last Post: 03-10-2011, 09:17 AM -
JApplet on MAC
By ld_pvl in forum Java AppletsReplies: 0Last Post: 08-23-2009, 01:40 PM -
JFrame to JApplet or JApplet to JApplet
By ramesh.8189 in forum AWT / SwingReplies: 13Last Post: 02-08-2009, 06:14 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks