changelistener

how can I get the value of a the selected item in a JSpinner?

一个人想着一个人 提交于 2019-12-03 08:41:15
I'm making an application that uses a JSpinner with a max number 30,I should choose a value from this JSpinner and tape a String to the JTextField and the result will appear in the Textarea,when I compile I have many problems concerning the method jSpinner1State,can any one help me because I don't know where is my problem. This is my code of the method JSpinner: jSpinner1.addChangeListener(this); private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) { // TODO add your handling code here: Object sp=jSpinner1.getValue(); int i =Integer.parseInt(sp.toString() ); String targetIP

IResourceChangeListener being called twice with one change

岁酱吖の 提交于 2019-12-02 15:41:04
问题 I'm using the IResourceChangeListener to listen for workspace/project changes. It's implemented as proposed by the Eclipse example: IWorkspace workspace = ResourcesPlugin.getWorkspace(); IResourceChangeListener resourceChangeListener = new IResourceChangeListener() { public void resourceChanged(IResourceChangeEvent event) { System.out.println("Something changed!"); } }; workspace.addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_BUILD); // some time later on ...

JMenuBar SelectionModel ChangeListener only fires once

时光毁灭记忆、已成空白 提交于 2019-12-02 07:22:05
问题 I am trying to get my JMenuBar to model the behavior of the menu bars of Firefox and iTunes. The behavior: the menu bar is initially hidden. But, when you press Alt , the menu bar appears (with the first item selected) and when you don't have a menu item selected, the menu bar disappears. My idea was to listen for selection changes to the JMenuBar via a ChangeListener on its SelectionModel . However, the behavior of the attached SSCCE is not as desired. When the frame loads, the JMenuBar is

IResourceChangeListener being called twice with one change

我们两清 提交于 2019-12-02 04:39:51
I'm using the IResourceChangeListener to listen for workspace/project changes. It's implemented as proposed by the Eclipse example: IWorkspace workspace = ResourcesPlugin.getWorkspace(); IResourceChangeListener resourceChangeListener = new IResourceChangeListener() { public void resourceChanged(IResourceChangeEvent event) { System.out.println("Something changed!"); } }; workspace.addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_BUILD); // some time later on ... workspace.removeResourceChangeListener(resourceChangeListener); I implemented this code in a relatively new

JMenuBar SelectionModel ChangeListener only fires once

心不动则不痛 提交于 2019-12-01 23:28:25
I am trying to get my JMenuBar to model the behavior of the menu bars of Firefox and iTunes. The behavior: the menu bar is initially hidden. But, when you press Alt , the menu bar appears (with the first item selected) and when you don't have a menu item selected, the menu bar disappears. My idea was to listen for selection changes to the JMenuBar via a ChangeListener on its SelectionModel . However, the behavior of the attached SSCCE is not as desired. When the frame loads, the JMenuBar is not visible. When you press Alt , the menu bar appears with the first menu selected (thanks to the

JSpinner giving old values

北城以北 提交于 2019-12-01 12:50:49
I am using couple of JSpinners in my project who display the hour and minutes. When the JSpinner is incremented or decremented i have to save the value to the database. But the problem is that the JSpinners are giving me old values. eg- If the time displayed is 09:30 and i increment the time to 10:30 , I am getting 09:30 as the returned value. I am using following code UPDATED SSCCE package spinnerupdation; import java.awt.Container; import java.awt.FlowLayout; import java.text.SimpleDateFormat; import java.util.Calendar; import javax.swing.JFormattedTextField; import javax.swing.JFrame;

JSpinner Value change Events

試著忘記壹切 提交于 2019-11-30 04:43:58
How to make the update immediately when the jSpinner value was changed. ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { jLabel.setText(e.getSource()); } }; spinner1.addChangeListener(listener); The code above doesnt change the label text automatically, it required you to click again anyplace to update. The answer is to configure the formatter used in the JFormattedTextField which is a child of the spinner's editor: formatter.setCommitsOnValidEdit(true); Unfortunately, getting one's hand on it is as long and dirty as the introductory sentence: final

JSpinner Value change Events

风格不统一 提交于 2019-11-29 02:11:07
问题 How to make the update immediately when the jSpinner value was changed. ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { jLabel.setText(e.getSource()); } }; spinner1.addChangeListener(listener); The code above doesnt change the label text automatically, it required you to click again anyplace to update. 回答1: The answer is to configure the formatter used in the JFormattedTextField which is a child of the spinner's editor: formatter

Why my ChangeListener reacts only for JMenu, and not for JMenuItem?

流过昼夜 提交于 2019-11-28 04:48:46
问题 Now, I have a JMenu, and some JMenuItems in it. I want my program to perform some action when JMenu's and JMenuItem's state is changed to "selected". I don't use MouseLitener's MouseOver, because I want user to be able to navigate in menu using keyboards too. Now, I wrote this listener: class MenuItemListener implements ChangeListener { @Override public void stateChanged(ChangeEvent arg0) { JMenuItem item = (JMenuItem) arg0.getSource(); if(item.isSelected()) System.out.println(item.getText()+

JavaFX ChangeListener not always working

ε祈祈猫儿з 提交于 2019-11-27 22:32:45
i have a JavaFX Application and in there a concurrency Task. While the Task is running, i want to append the message from updateMessage() to a TextArea because the binding doesn't append new text to the TextArea, i used a ChangeListener worker.messageProperty().addListener((observable, oldValue, newValue) -> { ta_Statusbereich.appendText("\n" + newValue); }); That is working but not on every change. I checked it with a System.out.println() and counted in the task from 1 to 300 for (Integer i = 1; i <= 300; i++) { updateMessage(i.toString()); System.out.println(i.toString()); } this println()