473,480 Members | 3,135 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

JProgressBar.setValue problem.

dmjpro
2,476 Top Contributor
HI friends I am recently working on Swing.
But face a strange Problem!

I pass a JProgressBar reference and there I am doing a lot of database operation or others. There JProgressBar.setValue is not working. Actually there i importing a data into database from file. In the loop I am setting the value. But it's not working.
Why does this happen??


Debasis Jana
Jan 18 '08 #1
4 4244
BigDaddyLH
1,216 Recognized Expert Top Contributor
You have to be careful from which thread you invoke most Swing methods:

Concurrency in Swing

You would think JProgressBar's setValue method would be thread-safe, but the API doesn't vouchsafe for this. When I use a JProgressBar and I am updating it from another thread, I play it safe and use EventQueue.invokeLater.
Jan 18 '08 #2
dmjpro
2,476 Top Contributor
You have to be careful from which thread you invoke most Swing methods:

Concurrency in Swing

You would think JProgressBar's setValue method would be thread-safe, but the API doesn't vouchsafe for this. When I use a JProgressBar and I am updating it from another thread, I play it safe and use EventQueue.invokeLater.
Ok Thanks.
I got your point and saw the link.
But if I want to dispatch the event from another Thread then what should I do?
Suppose I am calling the importing method and inside importing method I am updating the "setValue" after each row insertion.
How get I achieve?

Debasis Jana
Jan 18 '08 #3
JosAH
11,448 Recognized Expert MVP
But if I want to dispatch the event from another Thread then what should I do?
Have a look at the SwingUtilities class. It can start a Runnable in the
AWT thread for you. btw, never do any real work in that thread yourself, i.e. it makes
the GUIs react slow because their thread is busy doing your work.

kind regards,

Jos
Jan 18 '08 #4
Tian Angel
1 New Member
Actually I get in such problem ,too !
It almost drives me crazy ,but I don't know how to handle this.
May 22 '18 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
5797
by: ORC | last post by:
I will use FieldInfo to import values from a XML file into the fields of an objects. But how to convert to the proper type like in this: public void Load(object MyClass) { foreach( FieldInfo...
3
3093
by: Laurie | last post by:
Hi, I need to be able to manipulate field values within a structure using FieldInfo.GetValue and FieldInfo.SetValue, in VB.Nt 2003. The GetValue is working fine and makes it really easy for me...
15
8180
by: Charles Law | last post by:
I have adapted the following code from the MSDN help for PropertyInfo SetValue. In the original code, the structure MyStructure is defined as a class MyProperty, and it works as expected. There is...
5
3938
by: Dennis | last post by:
I have an array "t" where each element is a structure of type "testing". I want to use the FieldInfo class to set the values of the array element fields. I can read the field properties and...
6
12067
by: Mindy | last post by:
Hey, I am using SetValue to change the DataEntry property of a form to "YES". But It doesn't work. No error messages, but the property didn't change.Following is the what I am writing SetValue:...
2
2330
by: cwertman | last post by:
Ok, Im missing something simple here. I have an object o its a person , I want to "blank" out any properties that are a type of a collection The follwoing code will loop through and tell me if...
2
4530
by: =?Utf-8?B?Tm9yZW1hYw==?= | last post by:
Hi. Using VS2005, .NET 2.0. I have an xml document that I want to go through and set the values on attributes of elements. The elements are complex types defined in my schema (xsd) files. ...
2
3289
by: Lloyd Dupont | last post by:
I have a color chooser class class ColorPicker : Control { public byte R { get; set; } public byte G { get; set; } public byte B { get; set; } public Color Color { get; set; } } All are...
3
2611
by: =?Utf-8?B?TWFyayBELiAoR1kp?= | last post by:
I have a class which loads it own values at startup from a database. I've abridged the following a little, but given the following: public class AppSettings { int notNestedType; public class...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7061
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4503
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3015
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.