awt

Moving a rectangle in JPanel with arrow keys using KeyListener

半城伤御伤魂 提交于 2020-01-06 08:12:58
问题 I have been trying to make a JPanel move with the arrow keys. It has not been working. I believe it is my inner class that extends the KeyAdapter . I'm also not sure about the ActionListener implemented were it is. The other class I have made does not matter since it is just the frame. package jerryWorlds; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Jerry extends JPanel implements ActionListener{ int SizeX, SizeY, PosX, PosY, VelX, VelY; Image img; Timer

Why does Java's AWT's tray icon swallow events when displaying a message?

若如初见. 提交于 2020-01-06 07:28:07
问题 Using Java 8 and AWT I'm displaying a tray icon on Windows 10. I also use the tray icon to display notifications. While displaying this notification, the mouse listener in the icon won't issue the first pressed and clicked event. Here's the minimum example: import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; public class TrayIconDemo { public static void main(String[] args) { createTrayIcon(); } private static void createTrayIcon() { Image image = Toolkit

Mouse Jumping when I enter a label

半腔热情 提交于 2020-01-06 07:20:47
问题 A bit ago I posted a question on cursors here and I was wondering how do I get the cursor to stop jumping so what I mean is then I enter the jlabel it shows it like normal and then after a couple of seconds it jumps to a different place now when I added the frame drag method I added this code to stop this form happening this.setLocation(x - xMouse, y - yMouse); But I was wondering how would add it into this method Toolkit toolkit = Toolkit.getDefaultToolkit(); Image image = toolkit.getImage(

Mouse Jumping when I enter a label

感情迁移 提交于 2020-01-06 07:18:10
问题 A bit ago I posted a question on cursors here and I was wondering how do I get the cursor to stop jumping so what I mean is then I enter the jlabel it shows it like normal and then after a couple of seconds it jumps to a different place now when I added the frame drag method I added this code to stop this form happening this.setLocation(x - xMouse, y - yMouse); But I was wondering how would add it into this method Toolkit toolkit = Toolkit.getDefaultToolkit(); Image image = toolkit.getImage(

Event listeners and Mouse listeners

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-06 06:59:14
问题 I was wondering if it is possible to check if a JButton is double clicked using an event Listener instead of a mouse listener. Consider the following code; public void actionPerformed(ActionEvent arg0){ if (arg0.getClickCount() == 2){ System.out.println("You Doubled clicked"); } } I get an error saying getClickCount() is undefined for the type ActionEvent . Is the click or doubleclick of a mouse not also considered as an event? Thoughts. 回答1: You want to use a MouseAdapter . It permits you to

Java Applet, AWT Refresh, issue on Mac OS X 10.4

∥☆過路亽.° 提交于 2020-01-06 06:19:11
问题 We have a Java Applet built using AWT. This applet lets you select pictures from your hard drive and upload them to a server. The applet includes a scrollable list of pictures, which works fine in Windows, Linux and Mac OS X 10.5. We launch this applet via Java Web Start or within a web page. Our applet does not behave properly in Mac OS X 10.4, regardless of the version of Java (1.4 or 1.5). You can find a screenshot of the incorrect behaviour, when scrolling, here: http://www.lavablast.com

Draw an image of growing size in Java

佐手、 提交于 2020-01-05 17:38:12
问题 I have an application where I want to draw an image that grows in width over time. Specifically, the application listens to the microphone and computes a spectrogram every 6 milliseconds, and I want to draw the updated spectrogram when it comes in. I've been using java.awt.image.BufferedImage to draw the spectrograms, but only for pre-recorded files, so I have a fixed width for the image. What's the best way to do this for a streaming application, where I don't know a priori the width of the

2 apps in the same JRE, are getting different result from java.awt.Desktop.isDesktopSupported()

故事扮演 提交于 2020-01-05 08:56:30
问题 I have a Maven Project that uses java.awt.Desktop . I'm using it for Google Authentication, so I need some way to open a browser dialog for Google Login, and user confirmation. I'm exporting that library in a .jar file, that I intend to include it in lots of Liferay Portlets, in WEB-INF/lib If I test the standalone project, running from the Liferay's Tomcat jre, Everything works fine, and Desktop.isDesktopSupported() returns true . When a portlet, deployed on the Same Tomcat , calls the same

Getting Applet not initialized error

最后都变了- 提交于 2020-01-05 08:00:34
问题 is everything is right in my programme?? When i run it the a screen appears but it says that Applet is not initialized import java.applet.Applet; import java.awt.*; import javax.swing.*; public class JobseekerLogin extends Frame { public void CreateFrame(){ Frame frame = new Frame("Frame in Java Swing"); frame.setSize(400, 400); frame.setVisible(true); Label lb = new Label("Username"); add("East",lb); add("West",new TextArea("")); Label lb1 = new Label("Password"); add("East",lb1); add("West"

Trying to draw multiple polygons results in error

泪湿孤枕 提交于 2020-01-05 06:45:07
问题 Following my previous post here , I changed the code to : PolygonnerJframe.java import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Point; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.util.ArrayList; import java.util.Iterator; import javax.swing.JFrame; import javax.swing.JPanel; /** * * @author X2 * */ public class PolygonnerJframe { public static void main (String[] args)