JSlider update another JSlider problems


Hi , I am taking Java classes at a college level.
I am playing around with JSliders and an addChangeListener.

The gist of my code is I have two sliders, one is MPH the other is KPH. When one slider is slid, the two fields update and the other slider follows. if you move the other slider, the same happes.
My problems seems that when the addChangeListener updates the other slider, it calls the same addChangeListener and then they both stick at 0.

I am using an if statement to run seperate commands depending on which slider calls the addChangeListener.

in this code if I uncomment the statements to update the other slider in the addChangeListener then it doesnt work, with them commented, the other slider does not update.

Im stuck.

Posted On: Friday 21st of September 2012 11:30:36 PM Total Views:  222
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




Making seconds update

Hi. I am really very eager to learn java. I've read many books about it and had learned the language on my own. Can you please help. I have created a jframe with date and time. The date is okay but the time in seconds is not updating every second. How can I make it update each second. Here is my code. public void currentDate(){ Calendar calendar = new GregorianCalendar(); int month = calendar.get(calendar.MONTH); int year = calendar.get(calendar.YEAR); int day = calendar.get(calendar.DAY_OF_MONTH); int second = calendar.get(calendar.SECOND); int minute = calendar.get(calendar.MINUTE); int hour = calendar.get(calendar.HOUR_OF_DAY); lblDate.setText(month+1 +"/" +day +"/" +year); lblTime.setText(hour +":" +minute +":" +second); }
VIEWS ON THIS POST

154

Posted on:

Wednesday 19th September 2012
View Replies!

How to update changes made in JTree to xml file

, I have a xml file which i am parsing using a dom parser and displaying as a JTree. Now I want that if any changes are made in the JTree, the changes should get updated to the xml. Please help
VIEWS ON THIS POST

201

Posted on:

Wednesday 19th September 2012
View Replies!

JTextArea not updateing

When the user clicks on a particular component on my GUI a listener dispatches the code below which, in turn, executes a method that creates a system process to update the computer clock with network time servers. private static void startTimeSync() { // this will take a bit of time - 10 sec addCommentToLog("Local Time Sync started ..."); logTextArea.validate(); logTextArea.repaint(); LinuxSUDO.syncClockDebug(); addCommentToLog("INFO: Local time sync complete."); }
VIEWS ON THIS POST

161

Posted on:

Wednesday 19th September 2012
View Replies!

Copy JList multiselect to another JList

hi!!! i have one JList and show all resordset.... i want selected rows and copy another JList my code is: conn = DriverManager.getConnection("jdbc:mysql://localhost/basiuser=root&password=root"); listEdit.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); String s1 = (String)listEdit.getSelectedValue(); pstmt = (PreparedStatement) conn.prepareStatement("SELECT * FROM datasong WHERE lista="); pstmt.setObject(1, s1); rs = pstmt.executeQuery(); while (rs.next()) { listModel.addElement(new QueryResult(rs.getInt("id"),rs.getString("nome"), rs.getString("base"),rs.getString("testo"),rs.getString("lista"))); } list.setModel(listModel); pstmt.close(); conn.close();
VIEWS ON THIS POST

105

Posted on:

Friday 21st September 2012
View Replies!