awt

Add transparent JPanel upon AWT Component to paint on

不想你离开。 提交于 2019-12-02 04:27:02
问题 I've got a Problem: In my Java application I've got an AWT Component (cannot change that one) that streams and shows an avi-file. Now I want to draw upon this movie and thought about putting a transparent JPanel above it and draw on that one. This does not work since I either see the avi-stream or the drawn lines but not both. I read somewhere that AWT does not support transparency of components - but the panel is a JPanel which is able to do so. Can someone please help me with this one -

Adding a border to an image in Java

。_饼干妹妹 提交于 2019-12-02 04:02:07
I am trying to create an image that adds a border to an existing image on Java by copying the pixels from their old locations to new coordinates. So far, this is what I have done: public static NewPic border (NewPic p, int borderWidth, Pixel borderColor) { int w = p.getWidth(); int h = p.getHeight(); Pixel src[][] = p.getBitmap(); Pixel tgt[][] = new Pixel[h][w]; for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { tgt[y][x + y + borderWidth] = src[x][y]; // this is probably where I a messing up } } return new NewPic(tgt); } Not sure what I am doing wrong in the line where I commented.

Desktop.getDesktop().browse Hangs

此生再无相见时 提交于 2019-12-02 03:58:32
I'm working on an application in which if a user clicks on a link, I want it to open in their default browser. From what I've read, this should in theory work, however, when run on Linux (specifically Linux Mint 17.1), it hangs until the program is force-quit. I'm not particularly interested in having it open in WebView. Any alternatives or fixes that you all can think of? Thanks in advance. if(Desktop.isDesktopSupported()){ try{ Desktop.getDesktop().browse(new URI(url)); }catch (IOException | URISyntaxException e){ log.debug(e); } } You are not alone . This is a bug that appears to happen in

how to draw rectangle on java applet using mouse drag event

亡梦爱人 提交于 2019-12-02 03:51:30
问题 i am using java. i want to draw rectangle based on mousedrag event. if user dragging the mouse, then the rectangle on the applet should increase or decrease basing on current mouse coordinates. i have the following code. in the following code i am using [b]SelectionArea[/b] class which extends a canvas on which i am performing drawing operation. i am using [b]image[/b] variable in this class for double buffering to reduce flickering and to save the applet's previous state(i.e drawing content

drawPolygon keeps drawing lines from starting (mousePressed) location to current (mouseDragged) location

橙三吉。 提交于 2019-12-02 03:19:37
So, I'm trying to dynamically draw a Polygon starting from when I click the mouse until I stop dragging and release. Instead of, for the purpose of this question, a square outline being drawn when I click, drag down, then right-across, then up, then left-across, this is what happens: http://imgur.com/t8ZN3Pp Any suggestions? Notes: model.addPolygon() creates a Polygon with starting points and adds it to an ArrayList called 'polys' model.addPolygonPoint() adds points to this created polygon that is stored in 'polys' my paint function iterates through polys to paint public void mousePressed

close window on button click

我的梦境 提交于 2019-12-02 03:02:35
Hello, I am using Java Swing and I want to close a window on a button click. I don't know using an actionlistener as the best way to do this but currently I am having compilation errors with it so its must be incorrect. Here my code: public class assignment2 { public static void main(String[] args){ MyFrame f = new MyFrame(); //open the inital gui interface f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); //set it visibile } } //this is the initial gui screen, presenting user with options for which action they would like to take //al actions for the gui are commenced here

Drag rectangle on JFrame in Java

最后都变了- 提交于 2019-12-02 02:46:49
I want to draw rectangle based on mousedrag event. if user dragging the mouse, then the rectangle on the applet should increase or decrease basing on current mouse coordinates. i have the following code. in the following code i am using SelectionArea class which extends a canvas on which i am performing drawing operation. i am using image variable in this class for double buffering to reduce flickering and to save the applet's previous state(i.e drawing content of applet) but the code is working fine if i draw first rectangle. if i start to draw second rectangle the previously drawn rectangle

Printing an HTML file in java

徘徊边缘 提交于 2019-12-02 02:43:31
问题 I'm trying to print an HTML file my program generates, but it won't work. On Ubuntu, ".isSupported(Desktop.Action.PRINT)" return false, even though I have the gnome libraries installed, and on Windows 7, java throws the following exception: java.io.IOException: Failed to print file:/C:/Users/user/Documents/document.html. Error message: Unspecified error followed by a stacktrace. Below is the code, I'm using java.awt.Desktop. File doc = DocumentComposer.writeDocument(new File(System

How to implement idle task in Java Swing

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 02:42:17
I have a GUI app that is getting to be quite slow. I want to start introducing timing for various GUI tasks - however, many of our GUI actions trigger other actions which then "invoke later" to trigger other actions. Eventually, it all settles down and there's nothing more to do. At this time, I want to stop a timer and report how long that GUI "action" took. I figured the way to do this is to implement a method called invokeOnceIdle(Runnable task) . The method will execute the supplied task only once the AWTEventQueue is "empty". i.e. the supplied "task" should be the last thing in the queue.

How to draw a spiderchart above a existing JfreeChart

不问归期 提交于 2019-12-02 02:25:25
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.awt.Rectangle; import java.awt.RenderingHints; import java.awt.geom.AffineTransform; import java.awt