awt

How to draw moving and Running sine wave chart using JFree chart in java?

夙愿已清 提交于 2019-12-23 17:07:37
问题 I m using JFreeChart to draw Running or Moving Sine Wave in java with netbeans. I write code for it , but it does not like moving or running sine wave graph. So if you have any idea regarding that then suggest me. My code is below import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JPanel; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org

Canvas and InputMap

时光毁灭记忆、已成空白 提交于 2019-12-23 15:43:09
问题 I'm building a 2d game in Java and I decided to use Canvas on which I would display the images relevant to the current frame. I'm using Canvas because I've heard it is more efficient in terms of time than JPanel. Is it true? Also, I would like to add some input to the game through key bindings since key listeners could cause focus issues and are lower level construct: keylistener not working after clicking button (see answer). Is there a way to use key bindings with a Canvas? Or I would

Rotation transform not working properly in repaint when running thread

孤街浪徒 提交于 2019-12-23 15:39:12
问题 I have been working on trying to make this program work, even though I can't seem to find whatever is the problem. This program is made of the following 2 classes, no more, no less. It is basically supposed to draw a point on each click in the drawing zone, and on the 3rd click all points are connected. I still have to work on making it prettier and more accurate, but this part works. What doesn't work is what should follow : on the fourth click a thread should start (and it starts), and the

GUI in Java using Swing

99封情书 提交于 2019-12-23 15:24:41
问题 I really need some guidance on how to create a GUI in Java. I'm a student in college and it's one of the the thing they never focus on. I currently have the rest of my program set up and working and now I'm trying to make the GUI. I'm creating a new GUI class for this. (I'm under the impression that this is the best practice for this). I kind of understand how to make the basic setup but I don't understand how to interact with the the GUI afterwards. What I want to do is make a window on

Java how to draw and fill a Polygon which has holes

天大地大妈咪最大 提交于 2019-12-23 12:16:11
问题 I am currently trying to draw and fill a Polygon which has a hole in it in Java. Normally this would not be a big problem, since I would draw the exterior ring and then draw the interior ring with the color of the background. But the problem is, that the polygon is displayed above a image which should be "seen" through the hole. I am writing the code in Java and am using JTS Topology Suite for my geometry data. This is my current code, which just paints the border and fills the polygon with a

JPopupMenu display under Canvas

家住魔仙堡 提交于 2019-12-23 10:55:47
问题 I have a Canvas, some text fields and a context menu. When I start the application and right click on the canvas a popup menu shows. But when I write something inside the text field than I right click on the canvas, the popup will shows behind the canvas. Any idea how to fix that ? 回答1: JPopupMenu.setDefaultLightWeightPopupEnabled( false ); solved the issue. 回答2: 1) Canvas is AWT Component , and is Heavyweight type of Components 2) JPopupMenu is Swing JComponent and is Lightweight type of

Transparent Swing Windows

空扰寡人 提交于 2019-12-23 10:09:52
问题 I have a little JWindow with a logo on it that users can drag stuff to. I develop my application mainly on OS X. To get a transparent window i use setBackground(new Color(0,0,0,0)); On a mac this works beautifully but I can't get the same effect on windows. Is there any way to get a transparent window without using 1.6 specific features. I need 1.5 compatibility. 回答1: As of 1.5 Java does not support transparent windows. This feature is introduced as part of 1.6.10 release. See AWTUtilities

Making an Unfocusable Window in Java

旧时模样 提交于 2019-12-23 09:26:52
问题 (SOLVED: a WindowStateListener and a deferred call to toBack whenever the window is focused) Hello all! I've been trying to figure out how to make a java.awt.Window (any subclass will do) so that it cannot be brought to the front. I'm working on a Java "Samurize-like" program that appears below all the application windows and displays Widgets on the screen. Just like "Always on top windows with Java", I'm hoping for something simple, hopefully just a single method call, if possible, but I've

addMouseListener for a JPanel

佐手、 提交于 2019-12-23 07:46:44
问题 Today I have a problem.. My program make a 8x8 grid and show the coord when I click on a JButton . BUT I refuse to use JButton and I need to go for JPanel .. But my addMouseListener isn't working so I don't know how is it possible to fix that I'm searching since 4h..... package coordboutons; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class CoordBoutons extends JFrame { CoordBoutons() { super("GridLayout"); setDefaultCloseOperation(EXIT_ON_CLOSE); Container

The lines that I draw get removed when another line is drawn

拜拜、爱过 提交于 2019-12-23 06:38:40
问题 The lines that I draw get removed when another line is drawn. I am using mouse event to draw lines but when ever i draw the second line the first one get removed. I believe it has something to do with my points which keep changing the location of the coordinates where i want to draw the line as my click keep changing the points but i am not sure that's the reason; please help thanks in advance public class DrawOnComponent { public static void main(String args[]) throws Exception { JFrame f =