awt

Using awt with android

六月ゝ 毕业季﹏ 提交于 2019-11-26 09:50:38
问题 I have a Java Swing application which draws diagrams. It uses Graphics2D calls and awt objects such as Rectangle etc. At some point I might want to port this to Android. I understand that I can\'t use Graphics2D on Android, but can I still use the awt Rectangle, Font, Color (etc) classes. What I want to do is to isolate any code changes between the swing version and the Android version by adding an emulation layer so my Graphics2D calls can be converted to Android drawing calls. Is this

Is it safe to construct Swing/AWT widgets NOT on the Event Dispatch Thread?

时间秒杀一切 提交于 2019-11-26 08:51:17
问题 I\'ve been integrating the Substance look and feel into my application and ran into several problems regarding it\'s internal EDT (Event Dispatch Thread) checking routines. Substance absolutely refuses to construct UI classes outside of the EDT. I\'ve done plenty of Swing/AWT and I know most of the rules regarding the EDT. I use SwingWorker, SwingUtilties.invokeLater to modify components. I always though that components could be CONSTRUCTED outside of the EDT, but must be realized and

Zoom box for area around mouse location on screen [closed]

左心房为你撑大大i 提交于 2019-11-26 08:37:01
问题 Is there any way to create a dynamic Zoom Box in Java which will include e. g. 20x20pix area around the cursor (but even when cursor will move beyond the Frame of app) and which will be shown for example in a small JPanel? I\'m asking in context of a Color Chooser program. The last functionality need to be implemented is just that Zoom Box. 回答1: I'm sure there are a number of different ways that this could be achieved. This basically uses a separate component, which acts as the "zoom box".

What is java.awt.Component.getName() and setName() used for?

末鹿安然 提交于 2019-11-26 08:27:22
问题 What is java.awt.Component.getName() used for? It always seems to be null in the applications I build with NetBeans. I\'m thinking of storing some help text per component in it -- I don\'t want to use the tooltip, I have another panel where I\'ll show the help text. 回答1: Component.setName(..) is used in the JDK mostly by the look and feel implementation classes to set ID-like strings for each component, e.g. BasicOptionPaneUI might call it on a button component to set its name to "OptionPane

Problems with Java's Paint method, ridiculous refresh velocity

て烟熏妆下的殇ゞ 提交于 2019-11-26 07:49:28
问题 I\'m developing a very simple version of R-Type as work for the university, but despite it works, the craft velocity is a lot of slow, so the movement is ugly and clumsy. I use the method repaint for refresh the screen, there are others methods or ways best than it? Video of Movement Paint method at main Panel @Override public void paint(Graphics g) { super.paint(g); Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2

Drawing a Component to BufferedImage causes display corruption

妖精的绣舞 提交于 2019-11-26 06:49:30
问题 I am using the JScrollNavigator component described here, in order to provide a navigation window onto a large \"canvas-like\" CAD component I have embedded within a JScrollPane . I have tried to adapt the JScrollNavigator to draw a thumbnail image of the canvas to provide some additional context to the user. However, the action of doing this causes the rendering of my application\'s main frame to become corrupted. Specifically, it is the action of calling paint(Graphics) on the viewport

Getting RGB value from under mouse cursor

◇◆丶佛笑我妖孽 提交于 2019-11-26 06:48:50
问题 I am trying to build a program that detects the color that is under the mouse cursor and then displays the color and RGB values in a window on the screen. I am VERY new to Java so do not know much of anything. I have two codes I have worked on, with help from a friend, The first one gets the RGB values of a specific coordinate of a buffered image, and the other takes user defined RGB values and shows a pane with the color in it. My question is \"how do I get the program to detect the color

How to draw a tree representing a graph of connected nodes?

◇◆丶佛笑我妖孽 提交于 2019-11-26 04:26:40
问题 I want to display a tree in a Java GUI, but I dont know how. The tree represents a graph of connected nodes, like this: I should say that I have my own tree class: public class BinaryTree { private BinaryNode root; public BinaryTree( ) { root = null; } public BinaryTree( Object rootItem ) { root = new BinaryNode( rootItem, null, null ); } public BinaryTree( Object rootItem,BinaryNode a,BinaryNode b ) { root = new BinaryNode( rootItem, a, b ); } public int leavesCount(){ return BinaryNode

paintComponent() vs paint() and JPanel vs Canvas in a paintbrush-type GUI

邮差的信 提交于 2019-11-26 04:26:37
问题 I got some interesting ideas and criticism from this, this and this post (see last post for the code of the GUI in question). Nevertheless, I\'m still quite confused about some things. Mainly, what is the least expensive way of displaying user-introduces graphics? More specifically, I used a paintComponent() method from JPanel class by making an object of this class in the MouseDragged() method together with paintComponent(getGraphics()) method ( AuxClass2 and AuxClass1 accordingly).

How to bring a window to the front?

别来无恙 提交于 2019-11-26 03:40:18
We have a Java application that needs to be brought to the foreground when a telecontrol mechanism activates something in the application. In order to get this, we have realized in the called method of the class which represents the frame of our application (extension of a JFrame ) following implementation: setVisible(true); toFront(); Under Windows XP, this works the first time it is called, on the second time only the tab in the taskbar flashes, the frame doesn't come to the front anymore. Same goes for Win2k. On Vista it seems to work fine. Do you have any ideas? A possible solution is: