awt

“Always on Top” Windows with Java

匆匆过客 提交于 2019-11-26 03:39:36
问题 In Java, is there a way to have a window that is \"Always on top\" regardless if the user switches focus to another application? I\'ve searched the web, and all of the solutions lean to some sort of JNI interface with native bindings. Truly this can\'t be the only way to do it?.. or is it? 回答1: Try this method of the Window class: Window.setAlwaysOnTop(boolean) It works the same way as the default in the Windows TaskManager: switch to another app but it shows always on top. This was added in

What does SwingUtilities.invokeLater do? [duplicate]

你离开我真会死。 提交于 2019-11-26 03:24:17
问题 This question already has an answer here: SwingUtilities.invokeLater() why is it needed? 7 answers What does SwingUtilities.invokeLater do? Is it just delaying the execution of a block of codes inside its run method? What is the difference between calling an action within the invokeLater function or simply calling it at the end of the thread we want to be executed? Can anyone help me with what really does the invokeLater function do? 回答1: As other answers have said, it executes your Runnable

Java Animate JLabel

最后都变了- 提交于 2019-11-26 02:58:59
问题 So I am creating a basic application that I want to have a JLabel at the bottom of the screen that starts at the left bottom corner and moves, animation style, to the right bottom corner in a set time, and a static image in the center. To do this, I created a JFrame with a JPanel using BorderLayout. There is a JLabel with an ImageIcon added to BorderLayout.CENTER and a JPanel at BorderLayout.SOUTH. My code, while hastily written and far from pretty, is: import java.awt.BorderLayout; import

How do you import a font?

青春壹個敷衍的年華 提交于 2019-11-26 02:25:27
问题 I\'m wondering how you would go about importing a font. I\'m trying to use a custom downloaded font but since most computers that would go to run this would not have this font as it\'s not a default font. How would I go about making the font work even if they don\'t have the font? I\'m using it for a gameover screen and need to display a score with it and want the score text to be the same font. This is the image, In case it matters the font name on my computer is Terminal Edit: I\'m assuming

What does SwingUtilities.invokeLater do? [duplicate]

感情迁移 提交于 2019-11-26 01:59:35
This question already has an answer here: SwingUtilities.invokeLater() why is it needed? 7 answers What does SwingUtilities.invokeLater do? Is it just delaying the execution of a block of codes inside its run method? What is the difference between calling an action within the invokeLater function or simply calling it at the end of the thread we want to be executed? Can anyone help me with what really does the invokeLater function do? As other answers have said, it executes your Runnable on the AWT event-dispatching thread. But why would you want to do that? Because the Swing data structures

How to bring a window to the front?

旧城冷巷雨未停 提交于 2019-11-26 01:14:01
问题 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.

Java GUI frameworks. What to choose? Swing, SWT, AWT, SwingX, JGoodies, JavaFX, Apache Pivot? [closed]

旧城冷巷雨未停 提交于 2019-11-26 01:09:40
问题 There is quite a lot of gui frameworks out there for java, but what is recognized as today\'s framework of choice? The following is my understanding of the different frameworks, please correct me if im wrong. This is a very loosely defined set of questions, but i still think its valuable for anyone thinking of creating rich gui applications. AWT Is the very foundation of swing, it performs well but is lacking in advanced components. If you intend to create rich applications, AWT is probably

What is the difference between Swing and AWT?

China☆狼群 提交于 2019-11-26 00:57:09
问题 Can someone please explain me what\'s the difference between Swing and AWT? Are there any cases where AWT is more useful/advised to use than swing or vice-versa? 回答1: AWT is a Java interface to native system GUI code present in your OS. It will not work the same on every system, although it tries. Swing is a more-or-less pure-Java GUI. It uses AWT to create an operating system window and then paints pictures of buttons, labels, text, checkboxes, etc., into that window and responds to all of

Border with rounded corners & transparency

徘徊边缘 提交于 2019-11-26 00:48:59
问题 The following screenshot shows a test of TextBubbleBorder 1 . I would like to make the corners of the component that are outside the rectangle to be entirely transparent & show whatever component is beneath it. I found a way to restrict the BG color of a label to \'inside the border\' by setting a Clip (representing the area outside the rounded corners) on the Graphics2D instance and calling clearRect() . That can be seen in Label 1 . However you can see the downside of this approach when

Re-paint on translucent frame/panel/component.

和自甴很熟 提交于 2019-11-25 23:42:56
问题 I\'m trying to create a translucent window with Java on OSX and add a JLabel to it. This JLabel changes its text every second.... However the component is not repainting well. How can I solve this problem? I\'ve found the these articles, but I can\'t figure out how to solve it. If possible, please paste the fixing source code, here\'s mine: import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import java.awt.Color; import java.awt.Font; import java.util.Timer;