awt

What is AWT-Windows thread?

主宰稳场 提交于 2019-12-10 19:59:51
问题 When I am working with AWT, after calling the Toolkit.getDefaultToolkit() , I have printed the current running threads in my program. I would like to know what is that AWT-Windows thread that is running in the background. What does it do and why does it have 6 priority. Also, the line Thread[AWT-Windows,6,main] does the main mean that the thread is started in the main thread? Thanks in advance. 回答1: AWT is the Java Abstract Window Toolkit. The AWT thread should be handling all AWT events,

How to have rotated Ellipse shape in Java?

余生长醉 提交于 2019-12-10 19:32:53
问题 How to have rotated ellipse Shape in java? I.e. so that its semi-axes are not parallel to coordinate axes? P.S. I need not just draw this ellipse but have it in memory as a shape object. 回答1: Just take an Ellipse2D object and apply an AffineTransform rotation to it, no? AffineTransform.getRotateInstance(Math.PI / 4) .createTransformedShape(new Ellipse2D.Double(0, 0, 2, 1)); 来源: https://stackoverflow.com/questions/10872311/how-to-have-rotated-ellipse-shape-in-java

How to make a gif run once and stop in Java?

六月ゝ 毕业季﹏ 提交于 2019-12-10 18:13:22
问题 Basically I have a game where I want to play an explosion gif whenever the player (or an enemy) dies, but I want the gif to just play once. I have everything set up in a class and I have an ArrayList that gets explosions added to it when I need it to, and I currently have it set up to remove them once the gif's duration has been reached (using System.currentTimeMillis()). The only problem there is that it isn't exact, and sometimes the gif stops early and disappears, and sometimes it rolls

How to modify Java Control Panel selections (corresponding to deployment.properties file) from windows command prompt?

南楼画角 提交于 2019-12-10 18:12:21
问题 How to modify Java Control Panel selections (corresponding to deployment.properties file) from windows command prompt? Specifically, I am looking for command(s) which can effect change in "Action for local applets" selection, in "Custom Security Level Settings" window (click the "Settings..." button next to "Custom" setting for the "Security Level" slider in the Security tab in Java Control Panel) , from "Prompt user" to "Run without prompt" . This setting's default value changed with update

Why My JComponent is not displayed on top of backgound JFrame?

南笙酒味 提交于 2019-12-10 18:09:20
问题 Why My JComponent is not displayed on top of backgound JFrame? Please check the following code: class CounterFrame extends JFrame { /** * */ private static final long serialVersionUID = 1L; private MyPanel myComponent = new MyPanel(); private JLabel contentPane = new JLabel(new ImageIcon(getClass() .getResource("background/2.jpg"))); CounterFrame() { contentPane.setLayout(new GridBagLayout()); setContentPane(contentPane); add(myComponent); } } class MyPanel extends JPanel { /** * */ private

Java MouseEvents not working

为君一笑 提交于 2019-12-10 17:55:57
问题 This may be a stupid question, but I have to ask! I have the following code snippets that are supposed to run their corresponding methods when the user interacts with objects. For some reason, "foo" is never printed, but "bar" is. myJSpinner1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { System.out.println("foo"); //"foo" is not printed } }); myJSpinner2.addChangeListener(new java.awt.event.ChangeListener() { public void

Java: Holding the cursor in an area

醉酒当歌 提交于 2019-12-10 17:53:59
问题 For those of you who have played Madness Interactive, one of the most frustrating things is when the cursor leaves the game area, and you accidentally click. This causes the game to defocus and your character dies in a matter of seconds. To fix this, I'd like to make a java application that I can run in the background that will hold the cursor inside the screen until I press a key, like ESC or something. I see two ways of implementing this, but I don't know if either of them are workable.

Java awt.Robot: CTRL+ALT+DEL does not bring up desired screen

◇◆丶佛笑我妖孽 提交于 2019-12-10 17:17:20
问题 I just recently found out about the awt.Robot Library and I'm quite excited to get to use it. I thought I'd play a little prank on my friend and have the robot press control,alt,delete press the lock the computer button but I can't get the program to bring up the control alt delete screen. Here's my code: import java.awt.*; import java.awt.event.KeyEvent; public class Bot { public static void main(String[] args) { try { Robot bot = new Robot(); bot.delay(4000); bot.keyPress(KeyEvent.VK

What cursors are available through Cursor.getSystemCustomCursor?

拟墨画扇 提交于 2019-12-10 16:56:35
问题 java.awt.Cursor has a method getSystemCustomCursor(String name). The documentation there gives only one example of a name: "Invalid.16x16". That doesn't seem to work, but "Invalid.32x32" does. Through googling, I've found one other example of a useful working name: "MoveDrop.32x32". This method seems like it could be useful. For example, there is no predefined "working in background" (mixed arrow/hourglass) cursor but perhaps it's available through this method. Does anyone know what cursor

Graphics.drawString() Draws Over My Old String

二次信任 提交于 2019-12-10 15:56:29
问题 I'm working on simple counter. My problem is that drawString() method draws new string over the old one. How to clear the old one before? Code... package foobar; import java.awt.Color; import java.awt.Graphics; import javax.swing.JPanel; public class board extends JPanel implements Runnable { Thread animator; int count; public board() { this.setBackground( Color.WHITE ); count = 0; animator = new Thread( this ); animator.start(); } @Override public void run() { while( true ) { ++count;