swingutilities

How to fix “(java:22494): Gdk-WARNING…”

。_饼干妹妹 提交于 2021-01-28 11:10:02
问题 I am writing a javafx program and I need the panel to update at a constant rate. Right now it is set to update every second. But I got this error, which is usually (but not always) followed by a glitch in the panel when the whole scene becomes distorted (it like mirrors in on itself in a weird choppy x pattern. hard to explain). Full error: (java:22494): Gdk-WARNING **: 18:38:59.118: XSetErrorHandler() called with a GDK error trap pushed. Don't do that. This is the code I have for the timer:

Java Mouse Event Right Click

浪尽此生 提交于 2020-01-19 04:45:51
问题 On my three button mouse MouseEvent.BUTTON2 = Middle Click and MouseEvent.BUTTON3 = Right Click. Is this the case on a two button mouse? Thanks 回答1: To avoid any ambiguity, use the utilities methods from SwingUtilities : SwingUtilities.isLeftMouseButton(MouseEvent anEvent) SwingUtilities.isRightMouseButton(MouseEvent anEvent) SwingUtilities.isMiddleMouseButton(MouseEvent anEvent) 回答2: Yes, take a look at this thread which talks about the differences between platforms. How to detect right

Java Mouse Event Right Click

不羁岁月 提交于 2020-01-19 04:45:27
问题 On my three button mouse MouseEvent.BUTTON2 = Middle Click and MouseEvent.BUTTON3 = Right Click. Is this the case on a two button mouse? Thanks 回答1: To avoid any ambiguity, use the utilities methods from SwingUtilities : SwingUtilities.isLeftMouseButton(MouseEvent anEvent) SwingUtilities.isRightMouseButton(MouseEvent anEvent) SwingUtilities.isMiddleMouseButton(MouseEvent anEvent) 回答2: Yes, take a look at this thread which talks about the differences between platforms. How to detect right

Java Mouse Event Right Click

佐手、 提交于 2020-01-19 04:45:25
问题 On my three button mouse MouseEvent.BUTTON2 = Middle Click and MouseEvent.BUTTON3 = Right Click. Is this the case on a two button mouse? Thanks 回答1: To avoid any ambiguity, use the utilities methods from SwingUtilities : SwingUtilities.isLeftMouseButton(MouseEvent anEvent) SwingUtilities.isRightMouseButton(MouseEvent anEvent) SwingUtilities.isMiddleMouseButton(MouseEvent anEvent) 回答2: Yes, take a look at this thread which talks about the differences between platforms. How to detect right

Updating Swing GUI with while loop and delay

百般思念 提交于 2020-01-06 05:48:05
问题 I have a while loop that is supposed to update the program data and the GUI, but the GUI part freezes until the while loop is done executing. Here is my code: while(game.getCompTotal() < 17) { try { Thread.sleep(2500); } catch (Exception ex){ ex.printStackTrace(); } game.compHit(); // Program data update updateCardPanels(); // GUI update -- Does not update until the while loop finishes. if(game.checkCompBust()){ if(JOptionPane.showConfirmDialog(this, "Dealer Busted. Play again?") ==

IllegalArgumentException adding a window to a container.

ⅰ亾dé卋堺 提交于 2020-01-05 05:22:25
问题 I am new to Java swing. I do have a problem when invoking my Jframe from main class. It may be a duplicate but I cant find out why my code is not worked. So I am posting here. Mainclass public static void main(String[] args) { // TODO code application logic here SwingUtilities.invokeLater(new Runnable() { @Override public void run() { SendMail sendMail = new SendMail(); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(sendMail,BorderLayout.CENTER);

Java - Difference between SwingWorker and SwingUtilities.invokeLater()

早过忘川 提交于 2019-12-30 02:12:26
问题 SwingWorker is used for the following purposes: For running long-running tasks in a different thread so as to prevent the GUI from being unresponsive For updating GUI with the results produced by the long-running task at the end of the task through done() method. For updating GUI from time to time with the intermediate results produced and published by the task with the help of publish() and process() methods. SwingUtilities.invokeLater() can perform the above tasks as follows: Instead of

Main purpose of SwingUtilities invokeLater

ぐ巨炮叔叔 提交于 2019-12-29 01:32:12
问题 I have this code snippet import javax.swing.SwingUtilities; public class Client1 { public static void main( String[] args ) { SwingUtilities.invokeLater( new Runnable() { public void run() { //new MyWindow( "Bayog" ); new MyWindowV2( "Bayog" ); } } ); } } what is the difference if i will not use SwingUtilities? 回答1: Suppose the code within the run method modifies a UI element. If you try to execute that code from a non-UI thread, it will fail: all UI operations must be performed in the UI

Updating the LAF of a different class

那年仲夏 提交于 2019-12-25 14:42:54
问题 In a "Battleship" program I wrote, I included the possibility to change the "look and feel" of a program to SystemDefault, "Metal" (Java Default) or "Motif" (also included in Java). If you choose the desired LAF from a JComboBox (--> changes a predefined String, lookFeel ) and press a confirm button, UIManager.setLookAndFeel(lookFeel) is called, and also SwingUtilities.updateComponentTreeUI(this) and the method updateUI() with the following code: public static void updateUI() { /

Updating the LAF of a different class

↘锁芯ラ 提交于 2019-12-25 14:42:10
问题 In a "Battleship" program I wrote, I included the possibility to change the "look and feel" of a program to SystemDefault, "Metal" (Java Default) or "Motif" (also included in Java). If you choose the desired LAF from a JComboBox (--> changes a predefined String, lookFeel ) and press a confirm button, UIManager.setLookAndFeel(lookFeel) is called, and also SwingUtilities.updateComponentTreeUI(this) and the method updateUI() with the following code: public static void updateUI() { /