Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Swing-AWT JFrame Components Printing

Have Programming Question? Ask it here!
 
 
 


ravi kumar
JFrame Components Printing
0 Answer(s)      4 years and 4 months ago
Posted in : Swing AWT


hi sir
thanks a lot for your reply...
but i go through the link that you have specified
http://www.roseindia.net/java/example/java/swing/Print.shtml

and downloaded the codes and compiled it got errors
and i removed that error and i executed program
when i press print button it displays these
errors

at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

so what can i do to avoid and function it properly

and i have altered the PrintExample content like this

public class PrintExample extends JFrame implements ActionListener {
public static void main(String[] args) {
new PrintExample();
}

public PrintExample() {
super("Printing Swing Components");
WindowShow.setNativeLookAndFeel();

Container content = getContentPane();
JButton printButton = new JButton("Print");
printButton.addActionListener(this);
JPanel buttonPanel = new JPanel();
buttonPanel.setBackground(Color.white);
buttonPanel.add(printButton);
content.add(buttonPanel, BorderLayout.SOUTH);
DrawingPane drawingPanel = new DrawingPane();
content.add(drawingPanel, BorderLayout.CENTER);
setSize(520,500);
setVisible(true);
}

public void actionPerformed(ActionEvent event) {
PrintableDocument.printComponent(this);
}

class DrawingPane extends JPanel {
private int fontSize = 15;
private String message = "Name";
private int messageWidth;

public DrawingPane() {
setBackground(Color.white);
Font font = new Font("Serif", Font.PLAIN, fontSize);
setFont(font);
FontMetrics metrics = getFontMetrics(font);
messageWidth = metrics.stringWidth(message);
int width = messageWidth*5/3;
int height = fontSize*3;
setPreferredSize(new Dimension(width, height));

}

public void paintComponent(Graphics g) {

super.paintComponent(g);
Graphics2D graph = (Graphics2D)g;
graph.drawRoundRect(10, 10,480,380,10,10);
graph.drawLine(10,60 ,490,60);
graph.drawLine(320, 60, 320, 390);
graph.drawLine(10, 345, 490, 345);
graph.setPaint(Color.black);
graph.drawString("NAME :", 15,30);
graph.drawString("COURSE :",15 ,55 );
graph.drawString("CLASS :",270, 55);
graph.drawString("Amount :", 15,110);
graph.drawString("Balance :", 15,150);
graph.drawString("Total :", 15,340);
graph.drawString("Recieved :", 15,380);




}
}
}

does it print the rectangle lines and strings what i mentioned above sir
and also please go through the print button error sir please i need it for my complteion of my little project thanking you a lot sir

Advertisement
View Answers

Related Tutorials/Questions & Answers:
JFrame Components Printing - Swing AWT
JFrame Components Printing  hi sir i am doing a project so i am working in netbeans i have to print a JFrame it contains Labels and few textboxfields so i want to take the whole JFrame contents for printing so would you
JFrame components printing - Swing AWT
JFrame components printing  hi sir thanks a lot for your reply... PrintExample extends JFrame implements ActionListener { public static void main(String[] args) { new PrintExample(); } public PrintExample() { super("Printing
Advertisements
JFrame components printing - Swing AWT
JFrame components printing  hi sir thanks a lot for your reply... PrintExample extends JFrame implements ActionListener { public static void main(String[] args) { new PrintExample(); } public PrintExample() { super("Printing
JFrame Components Printing - Swing AWT
JFrame Components Printing  hi sir thanks a lot for your reply... PrintExample() { super("Printing Swing Components... this public class PrintExample extends JFrame implements ActionListener { public
JFrame
JFrame  write an application with a JFrame that five labels describing reasons that a customer might not buy your product(for example "Too expensive") every time the user clicks a Jbutton, remove one of the negative reasons
jframe
jframe  Create a JFrame for the Summervale Resort. Allow the user to view the information about different rooms available, dining options and activities offered. Include at least two options in each menu and display appropriate
JFrame
Jframe. How can i do it. Please help me to do it. Or what else can i have
printing in swing
printing in swing  How can i print payslip in swing
Components
Components in Flex4 is the simple extension of the components of Flex3. In this section, you will learns different types of spark components to be used in Flex4. Here is the list of spark components
applet printing
applets gridwise and in each applet i am drawing some graph so while printing whole... but while printing it is not getting printed on paper and rest everything it is printing
Refresh JFrame
Refresh JFrame  How to refersh a JFrame and its componets
printing in java
printing in java  hello i want to print a jInternalframe containing some lebels,but my printer sent me a paper with the following written on it: please what is the problem
Printing stars
Printing stars  I am a beginer and i have one assignment which couldnt give me any idea how to do it..The Question is "Get a string "001222014654" and print o/p as 0 - * 1- ** 2- * 4- ** 5-* 6-* I dont know how to split
Hiding a JFrame
javax.swing.*; import java.awt.event.*; class PassData extends JFrame { JTextField... java.awt.*; import java.awt.event.*; class NextPage extends JFrame { NextPage
Hiding a JFrame
javax.swing.*; import java.awt.event.*; class PassData extends JFrame { JTextField... java.awt.*; import java.awt.event.*; class NextPage extends JFrame { NextPage
Java program for printing document
Java program for printing document  can u send me the java program for printing the office document? email: ibrahimbest@gmail.com
Components
Java NotesComponents Components (also known as "widgets") are the basic..., ... Components are placed in a container (eg, JPanel). The visual arrangement of the components depends on the container's layout. When the user does
printing java series
printing java series  * *** ***** ******** ***** *** *   Post the format properly
Printing 2 arrays
Printing 2 arrays  Hi, I have 2 arrays: String [] head = {"Name", "Date of birth", "PPS number"}; String [] personal= {value1, value2, value3}; I... not work since I'm using GUI (JFrame) but below workaround worked for me
Printing server information
Printing server information  Hello, I am learning PHP language. I trying to fetch the server Information Print. How could i will printing the server... connected to your PC? This it best example for the Printing server Information
how to reset JFrame
how to reset JFrame  how to reset JFrame
printing example - Java Beginners
printing example  Is it possible to print java controls using print method? My problem is to print a student mark list using java? The mark list should like that of university mark list
Java Printing - Java Beginners
Java Printing  Can anybody plz help in giving the code for printing the contents of JPanel.. It contains JLabels and JTextFields only.. Plz.. Its urgetn.. Printing means sending the document to the Printer..  Hi Friend
refresh checkbox jframe
refresh checkbox jframe  How to refresh checkbox button in JFrame
printing hollow square
printing hollow square  Write an application (PrintingSquares.java) that prompts the user to enter the size of the side of a square, then displays a hollow square of that size made of asterisks. Your program should work
how printing landscape?
how printing landscape?  I have code which print some data from data base with "drawString()" and it works correct when I chose "Portrait" from "Print Dialog", but it does not work if chose "Landscape". Is any way to print
jframe background color not showing
jframe background color not showing  jframe background color is not showing. please suggest.   Just add the background color to JPanel and then add it to JFrame. For example .. JFrame myFrame = new JFrame(); JPanel
Printing ArrayList - JSP-Servlet
Printing ArrayList   I have a code in servlet like this ArrayList total = new ArrayList (); session.setAttribute("efg",total); RequestDispatcher rd; rd = request.getRequestDispatcher("/checkout.jsp"); rd.forward
printing series in java
printing series in java  1 123 12345 1234567 12345 123 1   Here is a code for the following pattern: 1 123 12345 1234567 12345 123 1 class Pattern{ public static void main(String[] args
jumping frame jFrame to jInternalframe
jumping frame jFrame to jInternalframe  Afternoon sir, I want to ask... and sub menu(employee). in Form Login(jFrame) have username(textfield1) and password(passwordfield1), in Menu(jframe) have Menu employee(jMenu),creaby(jlabel1
printing the following output using for loop
printing the following output using for loop  1 2 3 3 4 5 4 5 6 7
printing the following output using for loop
printing the following output using for loop  1 2 3 3 4 5 4 5 6 7
JFRAME - Java Beginners
javax.swing.*; import java.awt.event.*; public class MenuExample extends JFrame
Adding JTable into existing Jframe.
Adding JTable into existing Jframe.  i need to add JTable into this code pls help me.. package Com; import Com.Details; import java.awt.Color...("serial") public class AddPage extends JFrame { JDesktopPane pane = new
Adding JTable into existing Jframe.
Adding JTable into existing Jframe.  i need to add JTable into this code pls help me.. package Com; import Com.Details; import java.awt.Color...("serial") public class AddPage extends JFrame { JDesktopPane pane = new
Adding JTable into existing Jframe.
Adding JTable into existing Jframe.  i need to add JTable into this code pls help me.. package Com; import Com.Details; import java.awt.Color...("serial") public class AddPage extends JFrame { JDesktopPane pane = new
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to JFrame than
Printing Session Id Using Variable
Printing Session Id Using Variable  Hi, I am a learner in PHP language. Could any one guide me, how to print session Id using variable in PHP. Thanks
Declare components
Java NotesWhere to declare components Components are typically declared in one of several places: Field variables Some components should be declared...). This is the appropriate place to declare components which must be referenced after
how to move label in jframe in java?
how to move label in jframe in java?  please any one can give me code for moving a java label in Jframe
patterns printing using for loop in java
patterns printing using for loop in java  how to write the code for the pattern as: 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
Printing numbers up to N into a file
Printing numbers up to N into a file  I'd like to print the first N integers, that is, "1, 2, 3, 4, ..., N-1, N", say N equals 1000, or 10000 or whatever. I'd also like to have the result stored as a file instead of having
JFrame Button click to start play
JFrame Button click to start play  i made a game and and i add a button in new jframe and i want when i click it it start to play...can anyone help me
Components of J2EE application
Components of J2EE application  What are the components of J2EE application
java web application printing - WebSevices
into a notepad document on client side with proper formatting to help printing
 

 

 

DMCA.com