changelistener

Make multiple change firings lead to far fewer actions

好久不见. 提交于 2020-05-17 05:47:07
问题 I have a TextArea in which the user of my app can write things. A ChangeListener is also listening to the StringProperty "text" of this TextArea . Whenever the text content changes, ChangeListener.changed() , among other things, sets a "dirty" BooleanProperty to true on a central app object. Where "dirty" has the sense of "document needs saving". But I've just implemented a thing in my app whereby any time that the "dirty" Property gets set to true triggers a save-file-to-disk action,

Rendering a single point in a JFreeChart based on the current Value of a Slider

血红的双手。 提交于 2020-01-16 18:51:10
问题 I'm not yet as much into Java as I'd like to be, so I find my current task to be quite a bit challenging: A chart showing data gathered in another class. A slider whose end value is determined by the last entry of in the dataset used in the chart. The playbutton currently doesn't do anything except letting the slider tick in steps of 5 until it is paused again. My problem right now is: I am supposed to highlight one item at a time in the chart based on which value the slider currently shows.

Rendering a single point in a JFreeChart based on the current Value of a Slider

a 夏天 提交于 2020-01-16 18:50:53
问题 I'm not yet as much into Java as I'd like to be, so I find my current task to be quite a bit challenging: A chart showing data gathered in another class. A slider whose end value is determined by the last entry of in the dataset used in the chart. The playbutton currently doesn't do anything except letting the slider tick in steps of 5 until it is paused again. My problem right now is: I am supposed to highlight one item at a time in the chart based on which value the slider currently shows.

JSpinner giving old values

…衆ロ難τιáo~ 提交于 2019-12-30 12:51:12
问题 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

setOnPreferenceChangeListener is called when assigning listener to preference in Android

心已入冬 提交于 2019-12-25 05:00:43
问题 In my preferences screen I set listeners to some preferences on onCreate() . But I've noticed the listener is called every time the preference is loaded (probably on the onCreate()). Is there a way to prevent this ? I want of course the listener to be called only when the preference value in the given key is changed. Thanks 回答1: You can achieve that this way. You need to register your listener in onResume and unregister in onPause . This way it won't get called when your activity is created

Java isRollover() method does not produce an event in my swing application

风流意气都作罢 提交于 2019-12-22 06:29:59
问题 I am reading a great book called Swing: A Beginner's guide. There is this code in the book that creates a button and a label that alerts on button's state change events : //Demonstrate a change listener and the button model package swingexample2_6; import java.awt.*; import javax.swing.*; import javax.swing.event.*; public class ChangeDemo { JButton jbtn; JLabel jlab; public ChangeDemo() { //Create a new JFrame container JFrame jfrm = new JFrame("Button Change Events"); //Specify FlowLayout

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

这一生的挚爱 提交于 2019-12-21 02:46:06
问题 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

JTabbedPane ChangeListener

巧了我就是萌 提交于 2019-12-18 12:45:13
问题 I need to detect when the selected tab changes, and get its index. The following code works, but it fires the println as many times as the amount of tabs currently loaded: tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("Tab: " + tabbedPane.getSelectedIndex()); // Prints the string 3 times if there are 3 tabs etc } }); What is the correct way of doing this? Thank you in advance. 回答1: By JDK 6 Update 26 (Windows 7 64-Bit), I only

JavaFX - Using a ChangeListener on a ComboBox to populate a second ComboBox with multiple ArrayLists

Deadly 提交于 2019-12-13 04:18:33
问题 Right, i'm trying to create a program that allows a user to build a Space Marine (Warhammer 40k) army and theres a paticular portion of the program that i'm struggling with. This portion allows the user to select a 'Unit Type' from a ComboBox, then another ComboBox underneath is populated with all of the units for the 'Unit Type' you selected in the first ComboBox. For example if you selected the Elites 'Unit Type' in the first ComboBox then the second ComboBox should be populated with all

JavaFX - Using a ChangeListener on a ComboBox to populate another ComboBox with an ArrayList results in the ArrayList being empty

两盒软妹~` 提交于 2019-12-13 03:07:01
问题 I posted this question two days ago about attaching a ChangeListener to a ComboBox to dictate what output would be shown on a second ComboBox. To put this in short, the idea was that the first ComboBox shows some Unit Types, and depending on the Unit Type chosen would depend on the list of Units shown in the second ComboBox based on the Unit Type chosen. For example If you chose the "Elites" Unit Type in the first ComboBox the second ComboBox should be populated with all the "Elite" units.