awt

Drawing a line with arrow in Java

半世苍凉 提交于 2019-12-30 00:37:31
问题 Can anyone guide me how to code the arrow line in different direction. wa and wl is positive the rectangle will be on top of the x-axis. Below example shown if wl is negative and wa is positive. The code below shown how i code the rectangle shape. x1 is the varaible to state where to start at x axis. e1 is the length of the shape, wa1 and wl1 is the height. wsign to determine the height wa1 or wl1 should display at negative side or positive side. if (Math.abs(wl1) > Math.abs(wa1)) { y_scale =

How to disable java.awt.Graphics.fillRect(int x, int y, int width, int height)'s effect?

半世苍凉 提交于 2019-12-29 09:17:09
问题 It's the original image: I use java.awt.Graphics.fillRect(int x, int y, int width, int height) to add a coloured rectangle on the image. Graphics imageGraphics = image.createGraphics(); Color color = new Color(0,0,0,100); imageGraphics.setColor(color); imageGraphics.fillRect(0, 0, 800, 600); So the image has been inverted and looks like this: After that,I want to clear the black transparent rectangle partly and show the original image. imageGraphics.clearRect(100,100,100,100); But the effect

getting Exception : java.lang.IllegalArgumentException: cannot add to layout: constraint must be a string (or null)

你说的曾经没有我的故事 提交于 2019-12-29 09:08:26
问题 I am implementing browser kind of project and I am getting an exception. import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.Insets; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import chrriis.dj.nativeswing.swtimpl.NativeInterface; import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser; public class WebPageDisplay extends JPanel{ public WebPageDisplay() { super(new BorderLayout());

getting Exception : java.lang.IllegalArgumentException: cannot add to layout: constraint must be a string (or null)

百般思念 提交于 2019-12-29 09:08:13
问题 I am implementing browser kind of project and I am getting an exception. import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.Insets; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import chrriis.dj.nativeswing.swtimpl.NativeInterface; import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser; public class WebPageDisplay extends JPanel{ public WebPageDisplay() { super(new BorderLayout());

Java Panel Double Buffering

雨燕双飞 提交于 2019-12-29 07:03:19
问题 wondered if anyone could point me in the right directon, i have developed a pong game and it needs double buffering due to flickering. Iv tryed some of the post on here to try and make it work, but im still a beginner with the swing awt suff, any help would be amazing thanks. public class PongPanel extends JPanel implements Runnable { private int screenWidth = 500; private int screenHeight = 300; private boolean isPaused = false; private boolean isGameOver = false; private int playToPoints =

Java Panel Double Buffering

☆樱花仙子☆ 提交于 2019-12-29 07:03:06
问题 wondered if anyone could point me in the right directon, i have developed a pong game and it needs double buffering due to flickering. Iv tryed some of the post on here to try and make it work, but im still a beginner with the swing awt suff, any help would be amazing thanks. public class PongPanel extends JPanel implements Runnable { private int screenWidth = 500; private int screenHeight = 300; private boolean isPaused = false; private boolean isGameOver = false; private int playToPoints =

Interoperability between Graphics2D and GraphicsContext

你说的曾经没有我的故事 提交于 2019-12-29 04:45:15
问题 I am working with a group which is looking to target a graphics renderer in Java. At the moment I am trying to figure out whether targeting java.awt.Graphics2D will be forward compatible. Namely, can other libraries like JavaFX display renders from a Graphics2D instance? Is there interoperability between java.awt.Graphics2D and javafx.scene.canvas.GraphicsContext ? Or, if not between Graphics2D and GraphicsContext directly, is there any means of displaying a Graphics2D render in a JavaFX

Why does InvokeLater cause my JFrame not to display correctly?

社会主义新天地 提交于 2019-12-28 13:54:31
问题 Ok I've read an searched all over the web, and I've not found the solution to my problem yet, perhaps I'm missing something simple, hence here I am... I've got a rather large project, that handles work orders for a repair business. It's all database connected, many many pages of code, and classes. But i just added a short bit of code to the front end that essentially checks for new messages in our notes area. Anyway, I display a simple JFrame with two JLabel s while a separate thread queries

Java AWT drawString() does not display on window

放肆的年华 提交于 2019-12-28 07:02:25
问题 I am following the examples from Java : The complete reference 8th edition (JDK 7) on AWT and I cannot succeed to display a string on the window that appears. The size and title are set correctly and the window shows up. If I output a string on the console in the paint() method I see that it actually gets called a few times but the string does not appear on the window of my application. I can't see where I diverged from the example; I actually have a bit less code (they added a mouse listener

Move an Oval in java

非 Y 不嫁゛ 提交于 2019-12-28 06:54:10
问题 I made a mini code that draw oval and link each other , now i try to move the oval(Circle) but I have a problem (in coding) // Panneau.java public class Panneau extends JPanel { private int R = 20; private boolean isDrag = false; String text = "stack"; int x = 250, y = 200; int height = 50, width = 50; Random Rnd = new Random(); int rand=Rnd.nextInt(); int r=Math.abs(rand%250); int r2=Math.abs(rand%250); public Panneau() { addMouseListener(new MouseAdapter() { @Override public void