Hi Folks,
I don't know what I'm doing wrong but I can't seem to get output to be printed on the printer. I was working on an application and couldn't get printing to work so created the class below to try to figure out what I was doing wrong. All I'm trying to do in the code below is to print the variable Msg in the center of the page. What prints out is a blank page. Any assistance would be appreciated. I'm using Java 1.2.1 and NetRexx 1.148 Thanks in advance and Best Regards, Bob <:-)> /* Title ' TryPrint - Q and D Class To Try Printing '*/ import javax.swing. class TryPrint public extends JFrame adapter implements WindowListener,ActionListener properties Private FMenu = JMenu("File") FMenuExit = JMenuItem("Exit") FMenuPrint = JMenuItem("Print") Msg = "This is a test message" -- the message to print method TryPrint() public super("Print Test") Mbar = JMenuBar() MBar.Add(FMenu) setSize(100,200) FMenuPrint.AddActionListener(this) FMenuExit.addActionListener(this) FMenuPrint.setActionCommand("1001") FMenuExit.setActionCommand("1000") FMenu.add(FMenuPrint) FMenu.AddSeparator() FMenu.add(FMenuExit) setJMenuBar(Mbar) addWindowListener(this) setVisible(1) method FilePrint() public PrintPrefs = Properties() do Job = toolkit.GetdefaultToolKit().GetPrintJob(null,"TryPrint",PrintPrefs) If Job = null then do say "Print Cancelled" end else do --PageSize = Job.GetPageDimension() -- rumor has it that this doesn't work for some releases so... ScrRes = toolkit.getDefaultToolkit().GetScreenResolution() PageSize = Dimension(ScrRes * 8.5, ScrRes * 11) g = Job.GetGraphics() Fm = g.GetFontMetrics() g.SetFont(Font("Serif",Font.Bold,24)) g.DrawString(Msg,(PageSize.Width-fm.StringWidth(Msg))/2,PageSize.Height/2+fm .GetAscent()) g.Dispose() Job.End() end end method main(s=string[]) public static TryPrint() method WindowClosing(Evt=WindowEvent) Exit method ActionPerformed(Evt=ActionEvent) Command = Evt.GetActionCommand() select when Command = 1000 then Exit when Command = 1001 then FilePrint() otherwise say Command end ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to [hidden email] with the following message in the body of the note unsubscribe ibm-netrexx <e-mail address> |
Free forum by Nabble | Edit this page |