awt

Printing headers and footers in color?

╄→гoц情女王★ 提交于 2019-12-06 05:44:48
I am trying to create colored headers and footers when printing a JTable. Specifically, I am looking at getPrintable() in javax.swing.JTable, but MessageFormat does not give me the option to specify the color of the header or footer. How can I do it? clarification I am interested in setting the header/footers while printing. For example, notepad appends the filename as a header to what you print. update Seems like there is no standard way of doing this, can someone give me some workarounds? The only answer posted so far has nothing to do with printing(as in send to a printer, not displaying to

Should I be concerned using AWTUtilities.setWindowShape()?

三世轮回 提交于 2019-12-06 05:29:26
问题 I am using the AWTUtilities class in my application to create custom window shapes. As far as I know, there is no other way to do it. It is a requirement. The javadoc generation gives me this error: warning: com.sun.awt.AWTUtilities is Sun proprietary API and may be removed in a future release What exactly does this mean? I can use it, but it may stop working with any release? Why put it in, then? More importantly, and the real question here, if Sun takes it out, will they likely replace it

How to draw a Round rectangle in java with normal rectangle outline

匆匆过客 提交于 2019-12-06 05:12:15
问题 For my java application i need a Round rectangle with an outline that looks like a normal rectangle, like this I know you can do that by drawing a normal rectangle and a RoundRect inside it but i don't want to draw a RoundRect inside it because I want to draw something else in it. So a round rect with normal corners. How do I draw that in Java? The problem is that the rectangle looks like this if I use layers: The corners are filled up with the wrong color. How do I prevent that? 回答1: I can

Java AWT生成滑动验证码

╄→гoц情女王★ 提交于 2019-12-06 05:10:28
最近工作需要在登录时使用滑动验证码验证。 网上能查到的做法基本上都是使用一张已存在的实际图片作为滑块的图形模板,然后按照此模板做二重循环逐像素地从源图像抠出滑块以及新图。 这种方式优点就是可以控制每个像素,如改变局部的 Alpha 值、做局部的高斯模糊等。缺点也显而易见——太麻烦,且二重循环对内存也是不小的负担。 笔者的想法是:首先生成滑块 1)根据规定好的路径生成闭合区间;2)设置 Graphics2D 的渲染区间( setClip 方法);3)使用原图来渲染当前 Image( drawImage 方法)。最后在源图扣掉滑块的地方加上阴影。 研究了一下 Java 的 awt 图像处理,这里对这几天的成果做一个记录,本文仅涉及图像处理方面,去掉了其它业务逻辑。 生成闭合区间 Java awt中提供了 Shape 接口,来代表任意一种几何图形。考虑我们要实现如下滑块图形: 上图左边的滑块可以先简化为右侧,原理是一样的。右边的图像一共有A、B、C、D、E、F六个定点。其中CD之间是一段圆弧。Graphics2D的坐标系从左上角开始,x轴往下是正方向,y轴往右是正方向。先算出每个点坐标:A(0,0)、B(0,50)、C(15,50)、D(35,50)、E(50,50)、F(50,0)。 注意到H1'和H2'两个点,CD间的圆弧由三阶贝塞尔曲线表示,H1'和H2'就是此贝塞尔曲线的控制点

Java is not Synthesizing Italic Font Faces

不羁岁月 提交于 2019-12-06 04:05:47
问题 Main question: Is there a setting in OpenJDK that will synthesize italic font faces like the Oracle JDK does. Background: Using OpenJDK, when drawing text on a Graphics2D object, text will not appear with an oblique style unless there is an italic font face registered with the desired font family. Oracle's JDK does synthesize italic font faces. Swing components also are synthesized. Notes: Bold is synthesized, bold italic synthesizes just the bold weight. I am aware that for best results,

repaint() Method in Java

大城市里の小女人 提交于 2019-12-06 04:01:08
问题 I am playing around with the Java graphics class a little bit and I was just wondering--when is it necessary to call the method repaint() ? I tried commenting it out and it didn't seem to affect my output GUI. I've seen it used a lot in Java GUI code that I've read, though. Would anyone mind explaining when to use it and when not to use it? 回答1: The repaint() refreshes the view (component), so whenever you make any change on the component, you must call it. For instance, if you rotate the

Canvas object is not displaying, but location is updating correctly in Java Applet

狂风中的少年 提交于 2019-12-06 03:22:20
My basic bouncing ball Applet should have a ball moving around according to the values in loc variable, but nothing shows up. Printing out loc shows that the numbers/math behind moving it around and bouncing off boundaries is indeed working as it should, but nothing shows up. Looking at examples online I didn't see why my drawing/painting code wasn't working as intended. Here's what I have, issues are probably focused about halfway down where the Ball object is. I posted most of the program as it does compile/run if someone will run it. import java.awt.*; import java.applet.*; import java.awt

Why doesn't my repaint work?

风格不统一 提交于 2019-12-06 02:26:22
I'm stuck with a problem considering my Display class, which extends Canvas. A single thread is running within the very same class. In this thread, the repaint method is called. However, while the thread works fine, the paint method is never called! Here's my code (I left out everything unrelated): package display; public final class Display extends Canvas implements Runnable { private static final long serialVersionUID = 1L; private Frame frame; private GraphicsEnvironment ge; private GraphicsDevice gd; public BDisplay() { ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); gd = ge

Printing in Java using PS file

人走茶凉 提交于 2019-12-06 02:21:24
I have a generated post script file and want to print using it. How can it be achieved in java either using javax print API or AWT. Is it possible? Complicated. Does your printer(s) support PostScript? Is it networked? If so, most networked printers can talk LPR and you can shove the file over as-is. On Windows, you could also stream the file as-is to the lpt1: mapped port via something like NET USE LPT1: \\[Computer Name]\Printer /PERSISTENT:YES . If you're on a server and you do lots of PostScript handling and your printer infrastructure supports it, I would very much look into the LPR

Android: The type java.awt.Image cannot be resolved. It is indirectly referenced from required .class files

让人想犯罪 __ 提交于 2019-12-06 02:13:39
问题 I am using some java projects in my Android project . I gave reference to those projects by adding them in Java Build Path and Project References . After doing this i can access classes of java projects in my android project. but getting this error The type java.awt.Image cannot be resolved. It is indirectly referenced from required .class files what should i do now?? Do i need to add any JRE or something else would help?? 回答1: Found solution: go to project properties java build pata -> Add