Merge
This commit is contained in:
commit
e79baf708d
@ -171,3 +171,13 @@ FILES_NO_MOTIF_c = \
|
|||||||
GLXSurfaceData.c \
|
GLXSurfaceData.c \
|
||||||
AccelGlyphCache.c \
|
AccelGlyphCache.c \
|
||||||
CUPSfuncs.c
|
CUPSfuncs.c
|
||||||
|
|
||||||
|
ifeq ($(PLATFORM), macosx)
|
||||||
|
FILES_NO_MOTIF_objc = \
|
||||||
|
AWTFont.m \
|
||||||
|
AWTStrike.m \
|
||||||
|
CCharToGlyphMapper.m \
|
||||||
|
CGGlyphImages.m \
|
||||||
|
CGGlyphOutlines.m \
|
||||||
|
CoreTextSupport.m
|
||||||
|
endif # PLATFORM
|
||||||
|
@ -187,3 +187,14 @@ FILES_export2 = \
|
|||||||
java/awt/dnd/DnDConstants.java \
|
java/awt/dnd/DnDConstants.java \
|
||||||
sun/awt/CausedFocusEvent.java
|
sun/awt/CausedFocusEvent.java
|
||||||
|
|
||||||
|
ifeq ($(PLATFORM), macosx)
|
||||||
|
ifeq ($(HEADLESS), true)
|
||||||
|
FILES_export += \
|
||||||
|
sun/awt/SunHints.java \
|
||||||
|
sun/font/CCharToGlyphMapper.java \
|
||||||
|
sun/font/CFont.java \
|
||||||
|
sun/font/CFontManager.java \
|
||||||
|
sun/font/CStrike.java \
|
||||||
|
sun/font/CStrikeDisposer.java
|
||||||
|
endif # HEADLESS
|
||||||
|
endif # PLATFORM
|
||||||
|
@ -43,6 +43,10 @@ include $(BUILDDIR)/sun/awt/FILES_export_unix.gmk
|
|||||||
# compiled based on the motif version.
|
# compiled based on the motif version.
|
||||||
FILES_c = $(FILES_NO_MOTIF_c)
|
FILES_c = $(FILES_NO_MOTIF_c)
|
||||||
|
|
||||||
|
ifeq ($(PLATFORM), macosx)
|
||||||
|
FILES_objc = $(FILES_NO_MOTIF_objc)
|
||||||
|
endif # PLATFORM
|
||||||
|
|
||||||
ifeq ($(PLATFORM), solaris)
|
ifeq ($(PLATFORM), solaris)
|
||||||
ifneq ($(ARCH), amd64)
|
ifneq ($(ARCH), amd64)
|
||||||
FILES_reorder += reorder-$(ARCH)
|
FILES_reorder += reorder-$(ARCH)
|
||||||
@ -97,6 +101,10 @@ vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/../java2d/pipe
|
|||||||
vpath %.cpp $(SHARE_SRC)/native/$(PKGDIR)/image
|
vpath %.cpp $(SHARE_SRC)/native/$(PKGDIR)/image
|
||||||
vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)/robot_child
|
vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)/robot_child
|
||||||
|
|
||||||
|
ifeq ($(PLATFORM), macosx)
|
||||||
|
vpath %.m $(call NativeSrcDirList,,native/sun/font)
|
||||||
|
endif # PLATFORM
|
||||||
|
|
||||||
#
|
#
|
||||||
# Libraries to link in.
|
# Libraries to link in.
|
||||||
#
|
#
|
||||||
@ -192,13 +200,21 @@ CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/debug \
|
|||||||
$(EVENT_MODEL)
|
$(EVENT_MODEL)
|
||||||
|
|
||||||
ifeq ($(PLATFORM), macosx)
|
ifeq ($(PLATFORM), macosx)
|
||||||
CPPFLAGS += -I$(CUPS_HEADERS_PATH)
|
CPPFLAGS += -I$(CUPS_HEADERS_PATH) \
|
||||||
|
$(call NativeSrcDirList,-I,native/sun/awt) \
|
||||||
|
$(call NativeSrcDirList,-I,native/sun/font)
|
||||||
|
|
||||||
ifndef HEADLESS
|
ifndef HEADLESS
|
||||||
CPPFLAGS += -I$(MOTIF_DIR)/include \
|
CPPFLAGS += -I$(MOTIF_DIR)/include \
|
||||||
-I$(OPENWIN_HOME)/include
|
-I$(OPENWIN_HOME)/include
|
||||||
LDFLAGS += -L$(MOTIF_LIB) -L$(OPENWIN_LIB)
|
LDFLAGS += -L$(MOTIF_LIB) -L$(OPENWIN_LIB)
|
||||||
|
else
|
||||||
|
LDFLAGS += -framework Accelerate \
|
||||||
|
-framework ApplicationServices \
|
||||||
|
-framework Cocoa \
|
||||||
|
-F/System/Library/Frameworks/JavaVM.framework/Frameworks \
|
||||||
|
-framework JavaNativeFoundation \
|
||||||
|
-framework JavaRuntimeSupport
|
||||||
endif # !HEADLESS
|
endif # !HEADLESS
|
||||||
endif # PLATFORM
|
endif # PLATFORM
|
||||||
|
|
||||||
|
@ -2314,6 +2314,10 @@ LIBAWT_HEADLESS_DIRS:=$(JDK_TOPDIR)/src/share/native/sun/font \
|
|||||||
$(JDK_TOPDIR)/src/solaris/native/sun/java2d/opengl \
|
$(JDK_TOPDIR)/src/solaris/native/sun/java2d/opengl \
|
||||||
$(JDK_TOPDIR)/src/solaris/native/sun/java2d/x11
|
$(JDK_TOPDIR)/src/solaris/native/sun/java2d/x11
|
||||||
|
|
||||||
|
ifeq ($(OPENJDK_TARGET_OS),macosx)
|
||||||
|
LIBAWT_HEADLESS_DIRS+=$(JDK_TOPDIR)/src/macosx/native/sun/font
|
||||||
|
endif
|
||||||
|
|
||||||
LIBAWT_HEADLESS_CFLAGS:=-DHEADLESS=true \
|
LIBAWT_HEADLESS_CFLAGS:=-DHEADLESS=true \
|
||||||
-DX11_PATH=\"$(X11_PATH)\" -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
|
-DX11_PATH=\"$(X11_PATH)\" -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
|
||||||
$(CUPS_CFLAGS) \
|
$(CUPS_CFLAGS) \
|
||||||
@ -2328,6 +2332,12 @@ LIBAWT_HEADLESS_CFLAGS:=-DHEADLESS=true \
|
|||||||
-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/jdga \
|
-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/jdga \
|
||||||
$(foreach dir,$(LIBAWT_HEADLESS_DIRS),-I$(dir))
|
$(foreach dir,$(LIBAWT_HEADLESS_DIRS),-I$(dir))
|
||||||
|
|
||||||
|
ifeq ($(OPENJDK_TARGET_OS),macosx)
|
||||||
|
LIBAWT_HEADLESS_CFLAGS+=\
|
||||||
|
-F/System/Library/Frameworks/JavaVM.framework/Frameworks \
|
||||||
|
-F/System/Library/Frameworks/ApplicationServices.framework/Frameworks
|
||||||
|
endif
|
||||||
|
|
||||||
LIBAWT_HEADLESS_FILES:=\
|
LIBAWT_HEADLESS_FILES:=\
|
||||||
awt_Font.c \
|
awt_Font.c \
|
||||||
HeadlessToolkit.c \
|
HeadlessToolkit.c \
|
||||||
@ -2356,6 +2366,16 @@ LIBAWT_HEADLESS_FILES:=\
|
|||||||
AccelGlyphCache.c \
|
AccelGlyphCache.c \
|
||||||
CUPSfuncs.c
|
CUPSfuncs.c
|
||||||
|
|
||||||
|
ifeq ($(OPENJDK_TARGET_OS),macosx)
|
||||||
|
LIBAWT_HEADLESS_FILES+=\
|
||||||
|
AWTFont.m \
|
||||||
|
AWTStrike.m \
|
||||||
|
CCharToGlyphMapper.m \
|
||||||
|
CGGlyphImages.m \
|
||||||
|
CGGlyphOutlines.m \
|
||||||
|
CoreTextSupport.m
|
||||||
|
endif
|
||||||
|
|
||||||
LIBAWT_HEADLESS_REORDER:=
|
LIBAWT_HEADLESS_REORDER:=
|
||||||
ifeq ($(OPENJDK_TARGET_OS), solaris)
|
ifeq ($(OPENJDK_TARGET_OS), solaris)
|
||||||
ifneq ($(OPENJDK_TARGET_CPU), x86_64)
|
ifneq ($(OPENJDK_TARGET_CPU), x86_64)
|
||||||
@ -2382,7 +2402,13 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS,\
|
|||||||
REORDER:=$(LIBAWT_HEADLESS_REORDER), \
|
REORDER:=$(LIBAWT_HEADLESS_REORDER), \
|
||||||
LDFLAGS_SUFFIX_linux:=-ljvm -lawt -lm $(LIBDL) -ljava,\
|
LDFLAGS_SUFFIX_linux:=-ljvm -lawt -lm $(LIBDL) -ljava,\
|
||||||
LDFLAGS_SUFFIX_solaris:=$(LIBDL) -ljvm -lawt -lm -ljava $(LIBCXX) -lc,\
|
LDFLAGS_SUFFIX_solaris:=$(LIBDL) -ljvm -lawt -lm -ljava $(LIBCXX) -lc,\
|
||||||
LDFLAGS_SUFFIX_macosx:=-ljvm $(LIBCXX) -lawt $(LIBDL) -ljava,\
|
LDFLAGS_SUFFIX_macosx:=-ljvm $(LIBCXX) -lawt $(LIBDL) -ljava \
|
||||||
|
-framework Accelerate \
|
||||||
|
-framework ApplicationServices \
|
||||||
|
-framework Cocoa \
|
||||||
|
-F/System/Library/Frameworks/JavaVM.framework/Frameworks \
|
||||||
|
-framework JavaNativeFoundation \
|
||||||
|
-framework JavaRuntimeSupport,\
|
||||||
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_headless,\
|
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_headless,\
|
||||||
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
|
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import java.security.PrivilegedAction;
|
|||||||
import javax.print.*;
|
import javax.print.*;
|
||||||
import javax.print.attribute.PrintRequestAttributeSet;
|
import javax.print.attribute.PrintRequestAttributeSet;
|
||||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||||
|
import javax.print.attribute.standard.PageRanges;
|
||||||
|
|
||||||
import sun.java2d.*;
|
import sun.java2d.*;
|
||||||
import sun.print.*;
|
import sun.print.*;
|
||||||
@ -173,6 +174,19 @@ public class CPrinterJob extends RasterPrinterJob {
|
|||||||
if (nsPrintInfo != null) {
|
if (nsPrintInfo != null) {
|
||||||
fNSPrintInfo = nsPrintInfo.getValue();
|
fNSPrintInfo = nsPrintInfo.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
|
||||||
|
if (isSupportedValue(pageRangesAttr, attributes)) {
|
||||||
|
SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
|
||||||
|
// If rangeSelect is not null, we are using AWT's print dialog that has
|
||||||
|
// All, Selection, and Range radio buttons
|
||||||
|
if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
|
||||||
|
int[][] range = pageRangesAttr.getMembers();
|
||||||
|
// setPageRange will set firstPage and lastPage as called in getFirstPage
|
||||||
|
// and getLastPage
|
||||||
|
setPageRange(range[0][0] - 1, range[0][1] - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile boolean onEventThread;
|
volatile boolean onEventThread;
|
||||||
@ -225,7 +239,6 @@ public class CPrinterJob extends RasterPrinterJob {
|
|||||||
* the end of the document. Note that firstPage
|
* the end of the document. Note that firstPage
|
||||||
* and lastPage are 0 based page indices.
|
* and lastPage are 0 based page indices.
|
||||||
*/
|
*/
|
||||||
int numPages = mDocument.getNumberOfPages();
|
|
||||||
|
|
||||||
int firstPage = getFirstPage();
|
int firstPage = getFirstPage();
|
||||||
int lastPage = getLastPage();
|
int lastPage = getLastPage();
|
||||||
@ -242,42 +255,53 @@ public class CPrinterJob extends RasterPrinterJob {
|
|||||||
userCancelled = false;
|
userCancelled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EventQueue.isDispatchThread()) {
|
//Add support for PageRange
|
||||||
// This is an AWT EventQueue, and this print rendering loop needs to block it.
|
PageRanges pr = (attributes == null) ? null
|
||||||
|
: (PageRanges)attributes.get(PageRanges.class);
|
||||||
|
int[][] prMembers = (pr == null) ? new int[0][0] : pr.getMembers();
|
||||||
|
int loopi = 0;
|
||||||
|
do {
|
||||||
|
if (EventQueue.isDispatchThread()) {
|
||||||
|
// This is an AWT EventQueue, and this print rendering loop needs to block it.
|
||||||
|
|
||||||
onEventThread = true;
|
onEventThread = true;
|
||||||
|
|
||||||
printingLoop = AccessController.doPrivileged(new PrivilegedAction<SecondaryLoop>() {
|
printingLoop = AccessController.doPrivileged(new PrivilegedAction<SecondaryLoop>() {
|
||||||
@Override
|
@Override
|
||||||
public SecondaryLoop run() {
|
public SecondaryLoop run() {
|
||||||
return Toolkit.getDefaultToolkit()
|
return Toolkit.getDefaultToolkit()
|
||||||
.getSystemEventQueue()
|
.getSystemEventQueue()
|
||||||
.createSecondaryLoop();
|
.createSecondaryLoop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Fire off the print rendering loop on the AppKit thread, and don't have
|
||||||
|
// it wait and block this thread.
|
||||||
|
if (printLoop(false, firstPage, lastPage)) {
|
||||||
|
// Start a secondary loop on EDT until printing operation is finished or cancelled
|
||||||
|
printingLoop.enter();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
// Fire off the print rendering loop on the AppKit, and block this thread
|
||||||
|
// until it is done.
|
||||||
|
// But don't actually block... we need to come back here!
|
||||||
|
onEventThread = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fire off the print rendering loop on the AppKit thread, and don't have
|
printLoop(true, firstPage, lastPage);
|
||||||
// it wait and block this thread.
|
} catch (Exception e) {
|
||||||
if (printLoop(false, firstPage, lastPage)) {
|
e.printStackTrace();
|
||||||
// Start a secondary loop on EDT until printing operation is finished or cancelled
|
|
||||||
printingLoop.enter();
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
} else {
|
if (++loopi < prMembers.length) {
|
||||||
// Fire off the print rendering loop on the AppKit, and block this thread
|
firstPage = prMembers[loopi][0]-1;
|
||||||
// until it is done.
|
lastPage = prMembers[loopi][1] -1;
|
||||||
// But don't actually block... we need to come back here!
|
|
||||||
onEventThread = false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
printLoop(true, firstPage, lastPage);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
} while (loopi < prMembers.length);
|
||||||
} finally {
|
} finally {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
// NOTE: Native code shouldn't allow exceptions out while
|
// NOTE: Native code shouldn't allow exceptions out while
|
||||||
|
@ -395,6 +395,7 @@ JNF_COCOA_EXIT(env);
|
|||||||
|
|
||||||
#pragma mark --- Miscellaneous JNI ---
|
#pragma mark --- Miscellaneous JNI ---
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
/*
|
/*
|
||||||
* Class: sun_awt_PlatformFont
|
* Class: sun_awt_PlatformFont
|
||||||
* Method: initIDs
|
* Method: initIDs
|
||||||
@ -416,3 +417,4 @@ Java_sun_awt_FontDescriptor_initIDs
|
|||||||
(JNIEnv *env, jclass cls)
|
(JNIEnv *env, jclass cls)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -634,6 +634,8 @@ cmsFloat64Number ParseFloatNumber(const char *Buffer)
|
|||||||
cmsFloat64Number dnum = 0.0;
|
cmsFloat64Number dnum = 0.0;
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
|
|
||||||
|
if (Buffer == NULL) return 0.0;
|
||||||
|
|
||||||
if (*Buffer == '-' || *Buffer == '+') {
|
if (*Buffer == '-' || *Buffer == '+') {
|
||||||
|
|
||||||
sign = (*Buffer == '-') ? -1 : 1;
|
sign = (*Buffer == '-') ? -1 : 1;
|
||||||
|
@ -1021,6 +1021,8 @@ cmsStage* _cmsStageAllocLabV2ToV4curves(cmsContext ContextID)
|
|||||||
mpe = cmsStageAllocToneCurves(ContextID, 3, LabTable);
|
mpe = cmsStageAllocToneCurves(ContextID, 3, LabTable);
|
||||||
cmsFreeToneCurveTriple(LabTable);
|
cmsFreeToneCurveTriple(LabTable);
|
||||||
|
|
||||||
|
if (mpe == NULL) return NULL;
|
||||||
|
|
||||||
mpe ->Implements = cmsSigLabV2toV4;
|
mpe ->Implements = cmsSigLabV2toV4;
|
||||||
return mpe;
|
return mpe;
|
||||||
}
|
}
|
||||||
|
@ -1023,6 +1023,13 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
|||||||
|
|
||||||
// this is already supported in UnixPrintJob
|
// this is already supported in UnixPrintJob
|
||||||
catList.add(Destination.class);
|
catList.add(Destination.class);
|
||||||
|
|
||||||
|
// It is unfortunate that CUPS doesn't provide a way to query
|
||||||
|
// if printer supports collation but since most printers
|
||||||
|
// now supports collation and that most OS has a way
|
||||||
|
// of setting it, it is a safe assumption to just always
|
||||||
|
// include SheetCollate as supported attribute.
|
||||||
|
catList.add(SheetCollate.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// With the assumption that Chromaticity is equivalent to
|
// With the assumption that Chromaticity is equivalent to
|
||||||
|
@ -549,6 +549,8 @@ class WPathGraphics extends PathGraphics {
|
|||||||
userx += xAdvance;
|
userx += xAdvance;
|
||||||
userpos.x += xAdvance;
|
userpos.x += xAdvance;
|
||||||
deviceTransform.transform(userpos, devpos);
|
deviceTransform.transform(userpos, devpos);
|
||||||
|
devx = devpos.x;
|
||||||
|
devy = devpos.y;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
super.drawString(str, x, y, font, frc, targetW);
|
super.drawString(str, x, y, font, frc, targetW);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 6362683
|
* @bug 6362683 8012381
|
||||||
* @summary Collation should work.
|
* @summary Collation should work.
|
||||||
* @run main/manual Collate2DPrintingTest
|
* @run main/manual Collate2DPrintingTest
|
||||||
*/
|
*/
|
||||||
|
102
jdk/test/java/awt/print/PrinterJob/PrintLatinCJKTest.java
Normal file
102
jdk/test/java/awt/print/PrinterJob/PrintLatinCJKTest.java
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 800535
|
||||||
|
* @summary JDK7 Printing: CJK and Latin Text in string overlap
|
||||||
|
* @run main/manual=yesno PrintLatinCJKTest
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.print.PageFormat;
|
||||||
|
import java.awt.print.Pageable;
|
||||||
|
import java.awt.print.Printable;
|
||||||
|
import java.awt.print.PrinterException;
|
||||||
|
import java.awt.print.PrinterJob;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
public class PrintLatinCJKTest implements Printable, ActionListener {
|
||||||
|
|
||||||
|
static PrintLatinCJKTest testInstance = new PrintLatinCJKTest();
|
||||||
|
private PageFormat pf;
|
||||||
|
|
||||||
|
static String info =
|
||||||
|
"You need a printer for this test. If you have none, let "+
|
||||||
|
"the test pass. If there is a printer, press Print, send "+
|
||||||
|
"the output to the printer, and examine it. It should have "+
|
||||||
|
"text looking like this : \u4e00\u4e01\u4e02\u4e03\u4e04English.";
|
||||||
|
|
||||||
|
public static void showFrame() {
|
||||||
|
JFrame f = new JFrame();
|
||||||
|
JTextArea jta = new JTextArea(info, 4, 30);
|
||||||
|
jta.setLineWrap(true);
|
||||||
|
jta.setWrapStyleWord(true);
|
||||||
|
f.add("Center", jta);
|
||||||
|
JButton b = new JButton("Print");
|
||||||
|
b.addActionListener(testInstance);
|
||||||
|
f.add("South", b);
|
||||||
|
f.pack();
|
||||||
|
f.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int print(Graphics g, PageFormat pf, int pageIndex)
|
||||||
|
throws PrinterException {
|
||||||
|
|
||||||
|
if (pageIndex > 0) {
|
||||||
|
return Printable.NO_SUCH_PAGE;
|
||||||
|
}
|
||||||
|
g.translate((int) pf.getImageableX(), (int) pf.getImageableY());
|
||||||
|
g.setFont(new Font("Dialog", Font.PLAIN, 36));
|
||||||
|
g.drawString("\u4e00\u4e01\u4e02\u4e03\u4e04English", 20, 100);
|
||||||
|
return Printable.PAGE_EXISTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
try {
|
||||||
|
PrinterJob job = PrinterJob.getPrinterJob();
|
||||||
|
job.setPrintable(testInstance);
|
||||||
|
if (job.printDialog()) {
|
||||||
|
job.print();
|
||||||
|
}
|
||||||
|
} catch (PrinterException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
showFrame();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user