• Post Reply Bookmark Topic Watch Topic
  • New Topic

Some Help will do good !!!  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
'please try to help me'
I'm printing out a report and I print out components like JTextField, JTable, JLabel.
averything works okay accept for the JTable.
before I try to print out the JTable I use the methods scale() and translate() to manipulate the pointer from the Graphics2D object, when I set the scale() method less then .3 or when I use the method translate( int x, int y ) and I pass in the second argument a large number I get this Exception ! ! ! ! ! ! ! ! !
Exception occurred during event dispatching:java.lang.ArrayIndexOutOfBoundsException: -1 < 0 at java.util.Vector.elementAt(Vector.java, Compiled Code) at javax.swing.JTable$1.getValueAt(JTable.java:388) at javax.swing.JTable.getValueAt(JTable.java:1403) at javax.swing.JTable.prepareRenderer(JTable.java:2890) at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:968) at javax.swing.plaf.basic.BasicTableUI.paintRow(BasicTableUI.java:899) at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:811) at javax.swing.plaf.ComponentUI.update(ComponentUI.java, Compiled Code) at javax.swing.JComponent.paintComponent(JComponent.java, Compiled Code) at javax.swing.JComponent.paint(JComponent.java, Compiled Code) at Activity$PrintHandler.print(Activity.java:391) at sun.java2d.RasterPrinterJob.printPage(RasterPrinterJob.java:485) at sun.java2d.RasterPrinterJob.print(RasterPrinterJob.java:235) at Activity$PrintHandler.actionPerformed(Activity.java:349) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1066) at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1101) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:378) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:204) at java.awt.Component.processMouseEvent(Component.java:3166) at java.awt.Component.processEvent(Component.java, Compiled Code) at java.awt.Container.processEvent(Container.java, Compiled Code) at java.awt.Component.dispatchEventImpl(Component.java, Compiled Code) at java.awt.Container.dispatchEventImpl(Container.java, Compiled Code) at java.awt.Component.dispatchEvent(Component.java, Compiled Code) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java, Compiled Code) at java.awt.LightweightDispatcher.processMouseEvent(Container.java, Compiled Code) at java.awt.LightweightDispatcher.dispatchEvent(Container.java, Compiled Code) at java.awt.Container.dispatchEventImpl(Container.java, Compiled Code) at java.awt.Window.dispatchEventImpl(Window.java, Compiled Code) at java.awt.Component.dispatchEvent(Component.java, Compiled Code) at java.awt.EventQueue.dispatchEvent(EventQueue.java, Compiled Code) at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java, Compiled Code) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:92) at java.awt.Dialog.show(Dialog.java:365) at java.awt.Component.show(Component.java:834) at java.awt.Component.setVisible(Component.java:796) at Activity.setVisible(Activity.java:203) at Main$5.actionPerformed(Main.java:116) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1066) at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1101) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:378) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250) at javax.swing.AbstractButton.doClick(AbstractButton.java:226) at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:754) at java.awt.Component.processMouseEvent(Component.java:3166) at java.awt.Component.processEvent(Component.java, Compiled Code) at java.awt.Container.processEvent(Container.java, Compiled Code) at java.awt.Component.dispatchEventImpl(Component.java, Compiled Code) at java.awt.Container.dispatchEventImpl(Container.java, Compiled Code) at java.awt.Component.dispatchEvent(Component.java, Compiled Code) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java, Compiled Code) at java.awt.LightweightDispatcher.processMouseEvent(Container.java, Compiled Code) at java.awt.LightweightDispatcher.dispatchEvent(Container.java, Compiled Code) at java.awt.Container.dispatchEventImpl(Container.java, Compiled Code) at java.awt.Window.dispatchEventImpl(Window.java, Compiled Code) at java.awt.Component.dispatchEvent(Component.java, Compiled Code) at java.awt.EventQueue.dispatchEvent(EventQueue.java, Compiled Code) at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java, Compiled Code) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:92) at java.awt.EventDispatchThread.run(EventDispatchThread.java:83)
Thanks in advance
Yoel
------------------
Sun Certified Programmer for JAVA 2 Platform
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I post this topic in this forum, since I think the problem is with the methods scale() & translate().
Yoel
[This message has been edited by yoel stern (edited August 20, 2001).]
 
Fred Abbot
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yoel
The problem is you are trying to access an element in your vector thats not there
somewhere in a loop you are going to far
by the way what do the
translate() and scale() methods do and where can i find them?

[This message has been edited by Fred Abbot (edited August 20, 2001).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fred,
the methods are from Class Graphics2D.
public abstract void scale( double sx, double sy )
Concatenates the current Graphics2D Transform with a scaling transformation Subsequent rendering is resized according to the specified scaling factors relative to the previous scaling. This is equivalent to calling transform(S), where S is an AffineTransform represented by the following matrix:
[ sx 0 0 ]
[ 0 sy 0 ]
[ 0 0 1 ]

Parameters:
sx - the amount by which X coordinates in subsequent rendering operations are multiplied relative to previous rendering operations.
sy - the amount by which Y coordinates in subsequent rendering operations are multiplied relative to previous rendering operations
public abstract void translate( int x, int y )
Translates the origin of the Graphics2D context to the point (x, y) in the current coordinate system. Modifies the Graphics2D context so that its new origin corresponds to the point (x, y) in the Graphics2D context's former coordinate system. All coordinates used in subsequent rendering operations on this graphics context are relative to this new origin.
Overrides:
translate in class Graphics
Parameters:
x, y - the specified coordinates
Yoel
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
could someone please try to help me print out a JTable this is the code of the print method, my problem is when I use the method translate to position it if I pass the second argument a number larger then 17 I get the above exception, why do I get it whats wrong with the code, the reason why I want to put in a larger number is because I want to position it lower on the page

public int print(Graphics g,PageFormat pageFormat,int pageIndex)
{
if( pageIndex > 0 )
return Printable.NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D)g;
g2.translate( pageFormat.getImageableX(), pageFormat.getImageableY() + 5 );
g2.setColor( Color.black );
table.paint( g2 );

return Printable.PAGE_EXISTS;
} // end of must overwrite method print
Thank You
Yoel
[This message has been edited by yoel stern (edited August 21, 2001).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!