awt

How to draw a spiderchart above a existing JfreeChart

心已入冬 提交于 2019-12-02 06:00:28
问题 I have one a jfree chart which I can generate everytime I run the code. Now i want to override few more spider graphs on the same chart. please help me how to do that Above this i need to add one more spider chart using jfree. Here is my code for doing this chart. package com.rectrix.exide.pdfbox; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Paint; import java.awt.PaintContext; import java

java.security.AccessControlException when using java.awt.Robot class for screen capture in applet

扶醉桌前 提交于 2019-12-02 05:58:36
I require to capture a web page screen to store it on client's machine whenever client clicks print screen button. For this I googled and got that by embedding an applet with signature(trusted applet) in my jsp page i can do this. So I am trying with a simple applet for an standalone java class. On success I can try it for jsp after signing the applet. What I tried is: import java.applet.Applet; import java.awt.Graphics; import java.util.Date; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.awt.Dimension; import java.awt.Rectangle; import

ImageIO saves back to original size

浪尽此生 提交于 2019-12-02 05:54:22
I've been searching for some solutions from the internet yet I still haven't found an answer to my problem. I've been working or doing a program that would get an image file from my PC then will be edited using Java Graphics to add some text/object/etc. After that, Java ImageIO will save the newly modified image. So far, I was able to do it nicely but I got a problem about the size of the image. The original image and the modified image didn't have the same size. The original is a 2x3 inches-image while the modified one which supposedly have 2x3inches too sadly got 8x14 inches. So, it has gone

How do I call Graphics Method inside KeyListener?

懵懂的女人 提交于 2019-12-02 05:46:20
Ahead of time, I would like to say there have been many posts similar to this, however, none of them apply to me or none of them actually have any answer at all, and are outdated, meaning there could be new java features that could help me solve my problem. Anyway, I wanted to make a game where there is tennis rackets. Of course, they would have to rotate. In order to rotate, I must call my Graphics2D method inside my KeyListener. How would I do this WITHOUT adding a new Graphics2D variable inside my key listener method? Here is all the methods I have that involve accomplishing this goal:

How to make the main GUI thread 'wait' until a separate pop-up window is disappeared

Deadly 提交于 2019-12-02 05:17:58
I have an object which is invoked from the main GUI thread and shows a separate JFrame for a number of seconds and then disappear (with the use of a timer). Now I want to make the main GUI thread to wait until the pop-up JFrame window disappears. For example, on the main GUI code: // initiate the object and show the pop-up JFrame DisappearingJFrame djf = new DisappearingJFrame (); djf.show (); // now the main GUI thread should wait // and after the pop-up JFrame disappears, the rest of the code is then executed ... ... Any suggestion would be welcome. Thanks. Don't use a separate JFrame for

Repaint is not functioning properly as required

匆匆过客 提交于 2019-12-02 05:15:13
I have built a tetris game. Now in that I have used a JPanel for displaying content and the blocks (using the paintComponents() method). The problem is whenever I try to call the tetris program from another JFrame it does not paint at all. The code for my tetris main menu is: import javax.swing.*; import sun.audio.AudioPlayer; import sun.audio.AudioStream; import java.awt.*; import java.awt.event.*; import java.io.FileInputStream; import java.io.InputStream; @SuppressWarnings("serial") public class Tetris_MainMenu extends JFrame implements ActionListener { @SuppressWarnings("unused") public

Shapes combination in Java?

☆樱花仙子☆ 提交于 2019-12-02 05:00:18
Does java Shape interface contract and library routines allow combining multiple shapes into one object extending Shape interface? For example, may I define class Flower which will consist of several ovals for petals and core? Or the Shape supposes only one continuous outline? If so then is there any class in Java for holding multiple shapes, may be some class for vectorized graphics? To manipulate shapes in Java like you're describing, you want to use the Area class, which has these operations. Just convert a Shape to an Area with new Area(Shape) . Here is my attempt - using a rotate

Which is a better top level container for this design, JFrame with Jpanels, or JDesktop with JInternalFrames

时光怂恿深爱的人放手 提交于 2019-12-02 04:46:41
问题 I'm a beginner with Swing and AWT, I'm looking to build a GUI using Netbeans. My GUI requires three areas, that I'm currently thinking of as JPanels on a JFrame. I require a "Drawing" panel that will listen for mouse input and draw Java2D shapes. The drawing panel will be anchored to the top left. The other two areas are a "Properties" scroll pane, and a "Controller" scroll pane. The controller pane will determine which drawn elements will be displayed via buttons, and the properties scroll

Overlapping AWT lines and Swing JLabels

末鹿安然 提交于 2019-12-02 04:37:45
I have a problem in my application using line primitives and JLables . I try to explain it: I have to draw a vehicle route using lines to represent roads and JLabels to represent cities. I need the use of JLabels because each JLabel has a Listener that shows a dialog with information about the city. I redefine paint() method of my main JPanel . In that method I first in invoke the super.paint() , then I draw the lines and finally I add the Labels to the JPanel . The problem is that the lines overlap the labels regardless the matter the order of painting them. Is there any suggestion? You can

Switching Apps on Mac with AWT Robot only sometimes works

99封情书 提交于 2019-12-02 04:35:22
I'm trying to use Robot in order to switch apps, and then enter some text. To do this (on my mac), I'm pressing Meta, Tab, and then releasing Tab, Meta in this order: Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_META); robot.keyPress(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_META); This works, but only occasionally (about every 5 or six presses). I've tried calling Thread.wait() inbetween press and release, but this has no effect. Neither does trying to mask Tab with META_DOWN_MASK. I also tried using the JavaFX Robot (com.sun.glass.ui.Robot),