awt

SecondaryLoop.enter() not blocking until exit() is called on the EDT

霸气de小男生 提交于 2019-12-10 15:15:42
问题 Summary For some reason when I call SecondaryLoop.enter() on the AWT Event Dispatch Thread (EDT), it does not wait for SecondaryLoop.exit() to be called before unblocking. Background Since I think SecondaryLoop is not a very well-known class, I'll give a brief overview: In general, it is a bad idea to have any long-executing or blocking code running on the EDT because then your app will not be responsive to any events until that code terminates. The EventQueue.createSecondaryLoop() allows you

Swing - Is it possible to set the font color of 'specific' text within a JTable cell?

做~自己de王妃 提交于 2019-12-10 14:57:31
问题 I have a JTable where one column displays values in the following format: 423545(50),[7568787(50)],53654656,2021947(50),[021947],2021947(50),[8021947(50)] I am wondering if it is possible to display the values within square brackets in RED? I have been googling around for the last few days and have found several examples showing how to set the 'background' of a cell but not really how to change the font of a cell especially not a specific part of the text. public class myTableCellRenderer

Convert a list java.awt.geom.Point2D to a java.awt.geom.Area

戏子无情 提交于 2019-12-10 14:57:20
问题 I have a set of points that i want to turn into a closed polygon in Java. I'm currently trying to use java.awt.geom.Point2D and java.awt.geom.Area but can't figure out how to turn a group of the points into an Area. I think I can define a set of Line2Ds based on the points and then add those to the Areas, but that's a lot of work and I'm lazy. So is there an easier way to go. The problem is I have a list of lat/lon coordinates and want to build up an area that I can use for hit testing. Non

setPreferredSize does not work

南笙酒味 提交于 2019-12-10 14:30:11
问题 Code: import java.awt.Dimension; import javax.swing.*; public class Game extends JFrame { private static final long serialVersionUID = -7919358146481096788L; JPanel a = new JPanel(); public static void main(String[] args) { new Game(); } private Game() { setTitle("Insert name of game here"); setLocationRelativeTo(null); setLayout(null); setDefaultCloseOperation(EXIT_ON_CLOSE); a.setPreferredSize(new Dimension(600, 600)); add(a); pack(); setVisible(true); } } So I set the preferred size of the

Is it OK to use AWT with JavaFx?

我们两清 提交于 2019-12-10 14:03:10
问题 I need some functionality that I cannot find currently in JavaFX. Like the Robot or the Tray Icon. I know these tools do work with JavaFx applications. But is it ok to use them? Are there any considerations that I should care of? 回答1: Generally it's not advised. N.B.: using any AWT from JavaFX will start whole AWT stack which can increase memory/proc consumption. there could be threading conflicts between Glass (FX UI stack) and AWT, especially on Mac. So it maybe worth using Swing

GridBagLayout: How to set fixed column width?

╄→гoц情女王★ 提交于 2019-12-10 13:36:52
问题 I've been trying to set fixed column width in the following code for ages...The thing is that when I add a label to the panel on the left, then the width is incremented automatically...and i Would like the column width to be fixed... Could anyone help me please?? This is the code: import java.awt.AWTException; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt

How to find which libraries does Java Desktop API require on Linux?

自古美人都是妖i 提交于 2019-12-10 12:33:20
问题 I am trying to find a way how to determine which libraries does Java require for Desktop API to work, specifically the BROWSE function. I read a few guides, bug reports and workarounds, but none of them work. I was able to make it work on Debian by installing libgnome2-0 and gvfs-backends packages. The first one is typically recommended (by people solving the same problem), the second one was a lucky guess because it seems that the Desktop API required the vfs. However I can't make this work

Methods in Java which can change pixel values

家住魔仙堡 提交于 2019-12-10 12:25:35
问题 I am working on an animation kind of program in java and for visualization. I am using the swing and awt libraries. I looked at a dozen implementations of this and all of them use a paint Component method and then repaint() when they want to draw shapes on the JFrame. Is there some method that I can call from any class that I want that can for example change a single pixel value? I also want to make an array list with shapes: ArrayList<Rectangle> rectangles = new ArrayList<Rectangle>(); And I

How to move a circle automatically in java? [closed]

懵懂的女人 提交于 2019-12-10 12:24:25
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I am new to java GUI, and am trying to learn it. I want to move a circle on screen automatically(i.e not by pressing any key or doing any other action). I found a way to move it by doing some action but thats not what i needed. Please could anybody tell me the simplest way of

how to make a function on a Choice that will change the content of other Choice

不想你离开。 提交于 2019-12-10 11:48:51
问题 i have tried ActionListener and ItemListener but it wont work and also i have tried searching for codes and method that might work on it but i just dont find it mostly might be because JCombobox is more popular i gees so . this is the form of Java program. import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; public class HarderCode extends Frame { Choice Cb1; Choice Cb2; Choice Cb3; Label lbl1; Label lbl2; Label lbl3; Label lbl4; Label lbl5; TextField