awt

Trying to draw multiple polygons results in error

大兔子大兔子 提交于 2020-01-05 06:44:41
问题 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)

dispose() is not the same as setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

非 Y 不嫁゛ 提交于 2020-01-05 03:32:21
问题 I noticed that if setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) is set, closing the frame will end its Process in Task Manager, but if i implement WindowListener and manually dispose() the frame, Process will remain... probably because in new Runnable() i have something like this: new Runnable() { void run() { Jsch tunnel=new Jsch(); JFrame frame=new JFrame(); frame.addWindowListener(new WindowListener() { frame.dispose(); } ); // imagine that this is legal frame.setVisible(true); } } Anyone

Java AWT application window padding

≡放荡痞女 提交于 2020-01-04 09:21:29
问题 I'm trying to build a simple AWT application in Java. I want all of the containers in the main window to be separated by bit. I can accomplish this by setting the Hgap and Vgap in the BorderLayout constructor (see below.) However, I can't figure out how to put a cap between the containers and the edges of the main window. How do I add a few pixels of padding to the main window? import java.awt.*; import java.applet.Applet; public class LayoutTest extends Applet { public void init() {

Java AWT application window padding

不羁的心 提交于 2020-01-04 09:18:56
问题 I'm trying to build a simple AWT application in Java. I want all of the containers in the main window to be separated by bit. I can accomplish this by setting the Hgap and Vgap in the BorderLayout constructor (see below.) However, I can't figure out how to put a cap between the containers and the edges of the main window. How do I add a few pixels of padding to the main window? import java.awt.*; import java.applet.Applet; public class LayoutTest extends Applet { public void init() {

Calling function on windows close

我只是一个虾纸丫 提交于 2020-01-04 07:19:14
问题 Using Java: I have a GUI built using the netbeans GUI builder. The GUI class was created by extending a jFrame public class ArduinoGUI extends javax.swing.JFrame and the GUI displayed using: java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ArduinoGUI().setVisible(true); } } Therefore I don't have an actual frame object on which to call frame. , so how in this case can I override the windowClosed function, because I have to call a specific function to tidy up a serial

Calling function on windows close

人盡茶涼 提交于 2020-01-04 07:19:08
问题 Using Java: I have a GUI built using the netbeans GUI builder. The GUI class was created by extending a jFrame public class ArduinoGUI extends javax.swing.JFrame and the GUI displayed using: java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ArduinoGUI().setVisible(true); } } Therefore I don't have an actual frame object on which to call frame. , so how in this case can I override the windowClosed function, because I have to call a specific function to tidy up a serial

java image convolution

为君一笑 提交于 2020-01-04 06:34:53
问题 I am trying to apply smoothing filter to image . But I get this bug : java.awt.image.ImagingOpException: Unable to convolve src image at java.awt.image.ConvolveOp.filter(ConvolveOp.java:180) at ocr.Resolution.smoothing(Resolution.java:102) at ocr.Interface$ButtonListener.actionPerformed(Interface.java:332) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel

Windows Snap feature for undecorated windows?

好久不见. 提交于 2020-01-04 05:40:10
问题 Does anyone know of a way to allow undecorated windows to make use of this feature? The only other alternative would be to implement it all over again. Any ideas? Thanks. 回答1: dockable could be onĺy JToolBar or JInternalFrame inside translucent and un_decorated JFrame in Win7 来源: https://stackoverflow.com/questions/10721380/windows-snap-feature-for-undecorated-windows

Java game - how to stop player from walking over obstacles

元气小坏坏 提交于 2020-01-04 05:18:12
问题 I have made a very simple 2D Java game class made up of the general 2D game methods such as render and update, I have set up all my if statements so that the player moves around the map with the keyboard arrow input. I am now trying to set up what I have read is a collision detection, I know the basics of what I need to do because I did a lot of reading before I actually came here to ask the question, from what I have read it goes something like this: Make 2 rectangles Rectangle rectOne = new

Creating an Event Dispatch Thread safe semaphore

ⅰ亾dé卋堺 提交于 2020-01-04 00:23:32
问题 I've been trying to make a binary semaphore that will be able to safely block execution of a method running on the event dispatch thread (EDT) without actually blocking the thread from handling more events. This may initially seem impossible, but Java has some built-in functionality related to this, but I can't quite get it to work. Use Case Currently, if you show a modal swing dialog from the EDT, it will appear to block the EDT (because your method that displayed the modal dialog will not