awt

Should I be concerned using AWTUtilities.setWindowShape()?

不想你离开。 提交于 2019-12-04 10:10: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 with another way to do the same thing? Is that what the warning is for? I suppose I could just check for

Get screen coordinates of a node in javaFX 8

故事扮演 提交于 2019-12-04 09:58:45
问题 I am developing a JavaFX application on Windows 8.1 64bit with 4GB of RAM with JDK version 8u45 64bit. I want to capture part of the screen using Robot but the problem is that I can't get the screen coordinates of the anchor pane that I want to capture and I don't want to use snapshot because the output quality is bad. Here is my code. I have seen the question in this link Getting the global coordinate of a Node in JavaFX and this one get real position of a node in javaFX and I tried every

java sending keystrokes using robot class

大城市里の小女人 提交于 2019-12-04 09:35:55
问题 I know it's possible to send keystrokes in java using Robot Class , but is there any way to specify the target process when it's already started ? 回答1: The Robot will send the keystrokes to whichever application window is on top. To send keystrokes to a specific target, you will want to set the target as the platform's foreground window first. Doing this may require native code such as that provided by JNI or (what I use) JNA. If you desire to send keystrokes to a background window, I believe

repaint() Method in Java

大憨熊 提交于 2019-12-04 08:18:01
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? 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 graphical component, you must make a call to repaint() in order to see the change on the containing component

How to get the bars in a bar chart start from the x-axis in java? [closed]

时光怂恿深爱的人放手 提交于 2019-12-04 07:38:03
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . As you can see in the picture, the bars in the chart starts below the x-axis. How do I fix it so that it starts from the x-axis line? Please suggest me a fix and also I would be helpful to know where I am going wrong. private int PAD = 20; private int LPAD = 35; private int DPAD = 25; Graphics2D g2 = (Graphics2D

Java headless bicubic image resize

心不动则不痛 提交于 2019-12-04 07:31:58
I need to perform java image crop and resize without an X server. I tried several methods. the first method below works, but outputs a fairly ugly resized image (probably using nearest neighbor algorithm for the resize: static BufferedImage createResizedCopy(Image originalImage, int scaledWidth, int scaledHeight, boolean preserveAlpha) { int imageType = preserveAlpha ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB; BufferedImage scaledBI = new BufferedImage(scaledWidth, scaledHeight, imageType); Graphics2D g = scaledBI.createGraphics(); if (preserveAlpha) { g.setComposite

Get a color from the user as a String and use it in a method that accepts enum values?

廉价感情. 提交于 2019-12-04 07:01:15
问题 How to get a color from the user as a String and use it in a method that accepts Color enum values? The idea is to get a color that the user chooses and pass the value (or handle the situation any other way) to a method element.setBackground(java.awt.Color) . 回答1: I would create a Map<String, Color> and populate it with what String color names map to which Color objects. You can use java.awt.Color's own static Color constants, e.g. colorMap.put("BLACK", Color.BLACK); , or you can insert your

Swing timers basic functionality [closed]

跟風遠走 提交于 2019-12-04 06:59:52
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I'm new at java graphic design, and I would like you, if possible, to help me with an easy example to help me to get to understand the basic

Unusual gaps while using JSeperator - Java

六月ゝ 毕业季﹏ 提交于 2019-12-04 06:40:59
I have been working on a Swing GUI and getting some unusual and unwanted gaps after adding JSeperator , Any idea how to remove them? Or any other option to how to achieve this nicely! Visual Description Gaps are apparent before JLabel "Speed" and after JSlider . Related Code control.setLayout(new BoxLayout(control, BoxLayout.X_AXIS)); ...another code omitted... control.add(orientation); //JLabel control.add(norm); //JRadioButton control.add(back); //JRadioButton control.add(new JSeparator(SwingConstants.VERTICAL)); control.add(speedLabel); //JLabel control.add(speed); //JSlider control.add(new

Load fonts out of JAR-file and create AWT font (works) and register iText font (does not work)

此生再无相见时 提交于 2019-12-04 06:34:27
问题 I tried to write an applet that is able to create a PDF with an embedded font. Everything works as long as it is not in an JAR file. The following code part shows that I first create the AWT Font (which works fine with and without beeing stored in a JAR-file). Then I want to register an iText (5.0.3) font. But here comes the error: access denied (java.io.FilePermission http:\host\jarfile\fonts\EXAMPLE.ttf read) java.security.AccessControlException) . private String font = "fonts/EXAMPLE.ttf";