Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Option Explicit Public Sub Form_Load() JBGrid1.HeaderHeight = 0 JBGrid1.HeaderVisible = False JBGrid1.Parent.setShowGrid(False) JBGrid1.BorderStyle= fmBorderStyleNone JBGrid1.BorderColor=vbWhite JBGrid1.GridColor=vbWhite JBGrid1.Parent.disable JBGrid1.Cols = 3 Dim x As Integer For x = 0 To 99 JBGrid1.DataMatrix(x,1)= "row " & x & " / col 1" Next JBGrid1.Rows = x JBGrid1.Parent.setBorder(BorderFactory.createEmptyBorder()) End Sub Public Sub Command1_Click() JBGrid1.Parent.print() End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 |
'-> Import "...\overrideTablePrintable\TablePrintable.class" Import #TablePrintable Public Function getPrintable(ByVal myGrid As JTable, _ ByVal printMode As javax#swing#JTable$PrintMode, _ ByVal headerFormat As MessageFormat, _ ByVal footerFormat As MessageFormat) As Printable getPrintable = New #TablePrintable(JBGrid1, printMode, headerFormat, footerFormat) End Function |
Source code |
|
1 2 3 4 5 6 7 8 9 |
//Declare New class TablePrintable.class (MyPrintable) For the Return Type //Override the getPrintable-Method In your JTable. dataTable = New javax.swing.JTable(){ @Override Public Printable getPrintable( PrintMode printMode, MessageFormat headerFormat, MessageFormat footerFormat ) { Return New MyPrintable( this, printMode, headerFormat, footerFormat ); } }; |
Source code |
|
1 |
Import TablePrintable |
Source code |
|
1 |
javax#swing#TablePrintable |
Jabaco Source |
|
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 26 27 28 29 |
Option Explicit '### Base = SuperClass = e.g. JTable '### Me = this = this class '### Jabaco Properties Pane (on your right) -> set SuperClass -> javax/swing/JTable '### Import #TablePrintable '### hit F1 and import (Add Folder) -> Path of modified TablePrintable.class '### NOT: javax#swing#TablePrintable '### it might be a BUG in Jabaco, every time you open the Project '### you have to Import that class again; it does not stay in the Imports Window! '### in Form1 Dim jt As New #DrvdJTable() -> name of this class '### construct and add jt in Form1 Public Sub class_initialize() Debug.Print "init..." End Sub Public Function getPrintable(ByVal printMode As javax#swing#JTable$PrintMode, _ ByVal headerFormat As MessageFormat, _ ByVal footerFormat As MessageFormat) As #Printable Debug.Print "override getPrintable..." '### delegate to substitute class getPrintable = New #TablePrintable(Base, printMode, headerFormat, footerFormat) End Function |
Source code |
|
1 |
g2d.drawRect(0, 0, clip.width, hclip.height + clip.height); |
I know you are missing the modified TablePrintable.class here. The code is copyrighted and I do not know if I can just post it here.
Anyways since this is for private testing only...
I found the original code here:
http://kickjava.com/src/javax/swing/TablePrintable.java.htm
Quoted
I would also like to know:
am I realy importing "...\overrideTablePrintable\TablePrintable.class" with
Source code
1 Import TablePrintable
or could that also reference
Source code
1 javax#swing#TablePrintable
I know how to set classpath references -> F1 -> checkBoxes -> and so on, but I would like to know if I am setting the path to external classes in my code at designtime correctly?
And if not how would I do that in code?
Source code |
|
1 |
Import TablePrintable |
Source code |
|
1 |
javax#swing#TablePrintable |
Do you have any link to download a sole java compiler without all the overhead of a sun JDK?
Source code |
|
1 |
java -jar javac.jar Program.java |
Quoted
java -cp tools.jar com.sun.tools.javac.Main Program.java
Quoted
I would also like to know:
am I realy importing "...\overrideTablePrintable\TablePrintable.class" with
Source code
1 Import TablePrintable
or could that also reference
Source code
1 javax#swing#TablePrintable
Quoted
OK, well I managed to get it right, but how can I do all the referencing in code?
Quoted
How do I Set the SuperClass for a SubClass in code?
This post has been edited 2 times, last edit by "theuserbl" (Feb 13th 2013, 2:54am)
Quoted
It is everytime better to use the full path. then you are on the safe side. More than ever, if the class name existing more then one time.
...
Don't know, what you mean.
Jabaco Source |
|
1 |
Import #TablePrintable
|
Quoted
Quoted
How do I Set the SuperClass for a SubClass in code?
In Java? Width "extends".
In Jabaco? Create a new "Class Module" and set the SuperClass in the Properties-area on the right bottom of the Jabaco-window.
Jabaco Source |
|
1 |
javax#swing#TablePrintable |
Jabaco Source |
|
1 2 3 4 5 6 7 |
Public Function getPrintable(ByVal printMode As javax#swing#JTable$PrintMode, _ ByVal headerFormat As MessageFormat, _ ByVal footerFormat As MessageFormat) As java#awt#print#Printable Debug.Print "override getPrintable..." '### delegate to substitute class getPrintable = New #TablePrintable(Base, printMode, headerFormat, footerFormat) End Function |
Source code |
|
1 2 3 4 5 6 7 |
package javax.swing; import javax.swing.table.*; import java.awt.*; import java.awt.print.*; import java.awt.geom.*; import java.text.MessageFormat; |
Source code |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.text.MessageFormat; import javax.swing.JTable; import javax.swing.table.JTableHeader; import javax.swing.table.TableColumnModel; |
This post has been edited 1 times, last edit by "Dani" (Feb 13th 2013, 4:11pm)
Quoted
g2d.drawRect(0, 0, clip.width, hclip.height + clip.height);
Quoted
javax#swing#TablePrintable
Quoted
#TablePrintable
Quoted
I exchanged the one's of the new version and now it works with the .jar/.zip import.
Quoted
javax#swing#TablePrintable
as I wrote above in this thread, this is all I changed in the class
Quoted
g2d.drawRect(0, 0, clip.width, hclip.height + clip.height);
Jabaco Source |
|
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
package VBA; import javax.swing.table.*; import javax.swing.*; import java.awt.*; import java.awt.print.*; import java.awt.geom.*; import java.text.MessageFormat; class NewTablePrintable extends TablePrintable { private JTable table; private JTableHeader header; private TableColumnModel colModel; private int totalColWidth; private JTable.PrintMode printMode; private MessageFormat headerFormat; private MessageFormat footerFormat; private int last = -1; private int row = 0; private int col = 0; private final Rectangle clip = new Rectangle(0, 0, 0, 0); private final Rectangle hclip = new Rectangle(0, 0, 0, 0); private final Rectangle tempRect = new Rectangle(0, 0, 0, 0); private static final int H_F_SPACE = 8; private static final float HEADER_FONT_SIZE = 18.0f; private static final float FOOTER_FONT_SIZE = 12.0f; private Font headerFont; private Font footerFont; public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { // for easy access to these values final int imgWidth = (int)pageFormat.getImageableWidth(); final int imgHeight = (int)pageFormat.getImageableHeight(); if (imgWidth <= 0) { throw new PrinterException("Width of printable area is too small."); } // to pass the page number when formatting the header and footer text Object[] pageNumber = new Object[]{Integer.valueOf(pageIndex + 1)}; // fetch the formatted header text, if any String headerText = null; if (headerFormat != null) { headerText = headerFormat.format(pageNumber); } // *** Input the complete modified print-method here ** } } |
This post has been edited 1 times, last edit by "theuserbl" (Feb 15th 2013, 12:33pm)
Quoted
... class NewTablePrintable extends TablePrintable ...
Quoted
OOPJava.pdf