Click here to Skip to main content
15,889,176 members
Home / Discussions / Java
   

Java

 
GeneralRe: Putting a split String in a printout. Pin
Richard MacCutchan23-Oct-13 23:23
mveRichard MacCutchan23-Oct-13 23:23 
GeneralRe: Putting a split String in a printout. Pin
chdboy24-Oct-13 0:53
chdboy24-Oct-13 0:53 
Questionapplets Pin
Member 1035631323-Oct-13 18:28
Member 1035631323-Oct-13 18:28 
AnswerRe: applets Pin
Richard MacCutchan23-Oct-13 21:28
mveRichard MacCutchan23-Oct-13 21:28 
QuestionRe: applets Pin
Member 1035631324-Oct-13 16:30
Member 1035631324-Oct-13 16:30 
AnswerRe: applets Pin
Richard MacCutchan24-Oct-13 21:15
mveRichard MacCutchan24-Oct-13 21:15 
SuggestionRe: applets Pin
Member 1035631324-Oct-13 22:01
Member 1035631324-Oct-13 22:01 
QuestionSomething is wrong with the print command. Pin
chdboy21-Oct-13 3:31
chdboy21-Oct-13 3:31 
I'm not able to get the printout.

Here is the code.
Java
public class Billing extends Frame implements ActionListener,Printable
{
JButton printbtn = new JButton("Print");
}
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
throws PrinterException
{
if (pageIndex > 0)
{
return NO_SUCH_PAGE;
}
// User (0,0) is typically outside the
// imageable area, so we must translate
// by the X and Y values in the PageFormat
// to avoid clipping.
Graphics2D g2d = (Graphics2D)graphics;
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
// Now we perform our rendering
graphics.drawString("Hello world!", 100, 100);
// tell the caller that this page is part
// of the printed document
return PAGE_EXISTS;
// TODO Auto-generated method stub
}
public Billing
(
printbtn.addActionListener(this);
JPanel panel = new JPanel();
panel.setLayout(new MigLayout("debug,fillx,filly", "[]rel:push[]", "[]1[]"));
panel.add(printbtn);
frame.add(panel);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
)
@Override
public void actionPerformed(ActionEvent e)
{
else if (e.getSource().equals(printbtn))
{
System.out.println("You have clicked on Print Button!");
PrinterJob pj = PrinterJob.getPrinterJob();
job.setPrintable(this);
if (pj.printDialog() == true)
{
try
{
pj.print();
}
catch (PrinterException exc)
{
System.out.println(exc);
}
}
System.out.println("Print Job Ends Here!!!!XXXXX!!!!");
}
}

AnswerRe: Something is wrong with the print command. Pin
angrybobcat21-Oct-13 23:01
angrybobcat21-Oct-13 23:01 
GeneralRe: Something is wrong with the print command. Pin
chdboy21-Oct-13 23:37
chdboy21-Oct-13 23:37 
SuggestionRe: Something is wrong with the print command. Pin
Richard MacCutchan21-Oct-13 23:50
mveRichard MacCutchan21-Oct-13 23:50 
GeneralRe: Something is wrong with the print command. Pin
chdboy22-Oct-13 23:33
chdboy22-Oct-13 23:33 
GeneralRe: Something is wrong with the print command. Pin
Richard MacCutchan23-Oct-13 3:19
mveRichard MacCutchan23-Oct-13 3:19 
GeneralRe: Something is wrong with the print command. Pin
chdboy23-Oct-13 3:54
chdboy23-Oct-13 3:54 
Questionreplace Pin
Member 1030999420-Oct-13 2:21
Member 1030999420-Oct-13 2:21 
AnswerRe: replace Pin
Richard MacCutchan20-Oct-13 6:53
mveRichard MacCutchan20-Oct-13 6:53 
QuestionQuestion about java Pin
Araphat18-Oct-13 22:37
Araphat18-Oct-13 22:37 
AnswerRe: Question about java Pin
thatraja19-Oct-13 1:54
professionalthatraja19-Oct-13 1:54 
GeneralRe: Question about java Pin
Araphat21-Oct-13 3:55
Araphat21-Oct-13 3:55 
QuestionMalformedInputException in RandomAccessFile io Pin
Amer Rehman18-Oct-13 2:49
Amer Rehman18-Oct-13 2:49 
SuggestionRe: MalformedInputException in RandomAccessFile io Pin
Richard MacCutchan18-Oct-13 7:02
mveRichard MacCutchan18-Oct-13 7:02 
GeneralRe: MalformedInputException in RandomAccessFile io Pin
Amer Rehman19-Oct-13 9:14
Amer Rehman19-Oct-13 9:14 
QuestionAdd KeyListener to tabbedPane(Tab) Pin
chdboy17-Oct-13 21:44
chdboy17-Oct-13 21:44 
QuestionRe: Add KeyListener to tabbedPane(Tab) Pin
Richard MacCutchan18-Oct-13 0:48
mveRichard MacCutchan18-Oct-13 0:48 
AnswerRe: Add KeyListener to tabbedPane(Tab) Pin
chdboy18-Oct-13 20:44
chdboy18-Oct-13 20:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.