swing

Disable default ALT key action in JFrame under Windows

两盒软妹~` 提交于 2021-02-07 03:32:51
问题 I would like to let my JFrame under Windows not act upon an ALT key press. To clarify, when you execute the following snippet of code: import javax.swing.*; public class FrameTest { public static void main(String[] args) throws Exception { JFrame frame = new JFrame(); frame.setSize(400, 400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } and press the ALT key and then the arrow down key, you get a menu in the upper left corner in which you can choose to

Disable default ALT key action in JFrame under Windows

馋奶兔 提交于 2021-02-07 03:31:45
问题 I would like to let my JFrame under Windows not act upon an ALT key press. To clarify, when you execute the following snippet of code: import javax.swing.*; public class FrameTest { public static void main(String[] args) throws Exception { JFrame frame = new JFrame(); frame.setSize(400, 400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } and press the ALT key and then the arrow down key, you get a menu in the upper left corner in which you can choose to

How do I use swing in a shutdown hook?

本秂侑毒 提交于 2021-02-07 03:00:19
问题 Is there any possible way to add swing into a shutdown hook (that is, display a popup upon the VM shutting down)? I realize that if I try to make a new JFrame, it will give me an error, as it tries to register a shutdown hook, which fails as the VM is already shutting down. I'm just wondering if there is in fact any way around this 回答1: You really shouldn't be doing this. From the Runtime.addShutdownHook specification: The Java virtual machine shuts down in response to two kinds of events:

How do I use swing in a shutdown hook?

你说的曾经没有我的故事 提交于 2021-02-07 03:00:15
问题 Is there any possible way to add swing into a shutdown hook (that is, display a popup upon the VM shutting down)? I realize that if I try to make a new JFrame, it will give me an error, as it tries to register a shutdown hook, which fails as the VM is already shutting down. I'm just wondering if there is in fact any way around this 回答1: You really shouldn't be doing this. From the Runtime.addShutdownHook specification: The Java virtual machine shuts down in response to two kinds of events:

Is it possible to bring JFrame to front but NOT focus?

旧城冷巷雨未停 提交于 2021-02-06 15:17:26
问题 I'm writing a Java app (Swing GUI) that periodically pops up a JFrame. Is it possible somehow to bring the window to front (foo.setAlwaysOnTop(true) would be even better) but without having it focus? Some people move their eyes away from the screen from time to time to look at their keyboard while typing, and I'm sure that if this window would always capture the keyboard focus people would get really annoyed as it's causing them to lose quite a few keystrokes every time it pops up unnoticed.

HiDPI support in Java Swing for multiple look and feels

蓝咒 提交于 2021-02-06 12:59:08
问题 I'm looking to add Hi-DPI support to some Swing applications, but I have failed to find a solution sufficient to my needs. I need to support multiple look & feels, so the situation seems rather more complex than other posts I've found (which tend to suggest "adapt your UI sizes to match your font size"). Some experimentation has found the UIManager contains many metrics that can be tweaked to get you off to a good start in making an application Hi-DPI friendly. (The UIManager-Defaults utility

How to format a LocalTime variable

萝らか妹 提交于 2021-02-05 12:36:25
问题 I am quite new to Java windowbuilder, and this is part of my first project. String starttime = JOptionPane.showInputDialog(null, "What time would you like to start your revision ? (ie:12:24) "); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HH:mm"); LocalTime start = LocalTime.parse(starttime,dtf); I want to convert the format of start from ("HH:mm:ss..etc") to ("HH:mm") , but I get an error for the LocalTime.parse for some reason. Any suggestions what I should do. I'm using Joda Time

How to format a LocalTime variable

北慕城南 提交于 2021-02-05 12:33:33
问题 I am quite new to Java windowbuilder, and this is part of my first project. String starttime = JOptionPane.showInputDialog(null, "What time would you like to start your revision ? (ie:12:24) "); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HH:mm"); LocalTime start = LocalTime.parse(starttime,dtf); I want to convert the format of start from ("HH:mm:ss..etc") to ("HH:mm") , but I get an error for the LocalTime.parse for some reason. Any suggestions what I should do. I'm using Joda Time

How to restrict a JFileChooser to a custom file type? [closed]

大憨熊 提交于 2021-02-05 12:28:14
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Improve this question I am having slight trouble with JFileChooser . I want to restrict to only read certain kind of files. Another stack answer recommended using a FileNameExtensionFilter , but this doesn't seem to be working. This might be because I have to restrict it to a custom

How can I add some sound to my Java JFrame? [closed]

旧巷老猫 提交于 2021-02-05 12:20:05
问题 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 3 months ago . Improve this question I am making a Java game in JFrame. The game is almost completed but I want to add some sound to it. Like when the game will start, the sound should also start. I have checked the Internet but the codes are either not working or are very long. Can anyone help