changelistener

Java JTabbedPane - Action immediately before changing the selected Tab

非 Y 不嫁゛ 提交于 2019-12-12 03:37:53
问题 Using a JTabbedPane, I'd like to capture the moment just immediately before the change in the selection of a new tab is effective and perform an action. It'd be something analogous to a focus-lost event for a swing component. The aim is to save the text of a few JTextFields into an external file when the tab is changed, so everytime the user clicks a different tab, the values of the current tab are written into the external file. I've been using the ChangeListener to track the change of tabs,

Multiple JSliders - identifying changes

爱⌒轻易说出口 提交于 2019-12-11 19:17:07
问题 Am I able to add a change listener and define it on creation of a new JSlider? The order in which I need to create and add JSliders means I can't define them beforehand, so I don't really have a way to store them beforehand. Essentially: I don't have named JSliders, but need a way to identify which one has been altered. Will add to this with some example code later if it's not too clear what I am questioning about EDIT: Specifically, imagine I have one JSlider to represent a minimum value,

Not getting value from JSlider

穿精又带淫゛_ 提交于 2019-12-11 04:50:52
问题 I am using a JSlider in my program, and have implemented a ChangeListener for the same. public void stateChanged(ChangeEvent e) { JSlider source=(JSlider) e.getSource(); frame_value.setText(Integer.toString(source.getValue())); //Condition to change the frame_no only when user has stopped moving the slider if (!source.getValueIsAdjusting()) { frame_no=(int) source.getValue()-1; if(frame_no<0) frame_no=0; } .... } What is happening is, that whenever the ChangeListener is called, the program

RealmObject changeListener

泪湿孤枕 提交于 2019-12-11 02:25:17
问题 I'm trying to understand notification types in Realm from the Notifications section in the official docs, and when I'm using RealmObject addChangeListener in multiple managed object all of them are called when only one object is changing. This is my code Person first = realm.where(Person.class).equalTo("id", 0).findFirst(); first.addChangeListener(new RealmChangeListener<Person>() { @Override public void onChange(Person person) { Log.e(LOG_TAG, "First element is changing: " + person); } });

using ChangeListener to fire changes in Java Swing?

旧街凉风 提交于 2019-12-07 19:53:14
问题 I am implementing a word guessing game. The attached image gives an idea of what I am doing. My GamePane consists of two components, ControlPane and HangManPane , which is the top and bottom section of the attached image. when the player clicks, New Game button, the GamePane must be notified. subsequently, the GamePane will request the SecretWord from ControlPane and pass it on to HangManPane to construct the model. so two things happen here which I would like to know how to implement

using ChangeListener to fire changes in Java Swing?

送分小仙女□ 提交于 2019-12-06 05:32:21
I am implementing a word guessing game. The attached image gives an idea of what I am doing. My GamePane consists of two components, ControlPane and HangManPane , which is the top and bottom section of the attached image. when the player clicks, New Game button, the GamePane must be notified. subsequently, the GamePane will request the SecretWord from ControlPane and pass it on to HangManPane to construct the model. so two things happen here which I would like to know how to implement ControlPane should fire notifications when the user clicks "New Game" button.so this fireChange should happen

Implementing an ObservableValue

我怕爱的太早我们不能终老 提交于 2019-12-05 20:34:31
问题 I have this object: public class Oggetto{ private int value; private boolean valid; public Oggetto(int value, boolean valid) { this.value = value; this.valid = valid; } public int getValue() { return value; } public void setValue(int value) { this.value = value; } public boolean isValid() { return valid; } public void setValid(boolean valid) { this.valid = valid; } } and I would like implement an Observable object that fires events when something inside changes Here the observable object:

JavaFX: Bind StringProperty with constant string prefix

允我心安 提交于 2019-12-05 15:31:39
问题 I have a question to the bind functionality in JavaFX. What I want is to bind 2 string properties. But their values should not be equal. Let's make me an example: I have a StringProperty with represents the last opened project in my application. The value is like "C:\temp\myProject.prj". I want to show this path in the title of my window. It's easy: stage.titleProperty().bind(lastprojectProperty()); But I don't want to show only the project path but also the application name, e.g.:

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

守給你的承諾、 提交于 2019-12-05 10:38:18
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 for the layout manager jfrm.getContentPane().setLayout(new FlowLayout()); //Give the frame an initial

JavaFX: Bind StringProperty with constant string prefix

孤街醉人 提交于 2019-12-04 01:48:15
I have a question to the bind functionality in JavaFX. What I want is to bind 2 string properties. But their values should not be equal. Let's make me an example: I have a StringProperty with represents the last opened project in my application. The value is like "C:\temp\myProject.prj". I want to show this path in the title of my window. It's easy: stage.titleProperty().bind(lastprojectProperty()); But I don't want to show only the project path but also the application name, e.g.: MyApplication 2.2.4 - C:\temp\myProject.prj. It's possible to use the binding and add a constant prefix string?