Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!

Rob Camick

Rancher
+ Follow
since Jun 13, 2009
Cows and Likes
Cows
Total received
19
In last 30 days
0
Total given
0
Likes
Total received
570
Received in last 30 days
4
Total given
16
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rob Camick

Crossposted: https://stackoverflow.com/questions/52845609/how-do-i-uncheck-a-jcheckbox-that-i-am-using-as-one-of-my-header-columns/52856949#comment92645883_52856949

You were asked to post a SSCCE that demonstrates the problem (and you were given suggestion on how to do this)

We can't compile or test your code.

All you did was completely ignore the suggestions from you other questions and dump the code here.

1 day ago

It is about the art of getting your program to do what it should do, the layout is relatively unimportant.



If you spend time learning the IDE, then that knowledge is lost when you move to a different platform and the code won't be maintainable in the IDE editor since each IDE will generate different code.

And if you ever need to change the layout and update the code outside of the IDE, good luck trying to understand the GroupLayout code that is generated.

Which is why I would rather spend time learning Java/Swing and write the code myself. I can logically group the code to make it easier to understand and maintain.

An IDE is great to help compile, add code and debug, but don't let it dictate the structure of your code.

1 week ago

I do some database (MySql) operations



Any long running task needs to execute on a separate Thread so it doesn't block the Event Dispatch Thread (EDT) which is the Swing Thread that responds to user events and paints the GUI.

One way to do this is to use a SwingWorker.

You were given a link to the Swing tutorial above. There is also a section on Concurrency in Swing which will explain more about the EDT and the SwingWorker class.
1 week ago
Use a Swing Timer if you want to schedule some event.

You can schedule the event to first every second.

When the Timer fires you decrement the time remainting.

When the Timer remaining reaches 0, you stop the time and do your other processing.
1 week ago
Your question is about a scrollbar.

So post an SSCCE demonstrating the problem.

We don't have access to your databse to demonstrate the problem with hard coded data so we can compile and test the code to see what is happening.

When you post the code make sure you use the code formatting tags so the code is formatted and we can read it easier.
1 week ago

I wasnt able to try to figure out that the SQL Command should be moved outside the for loop, for it to be working,



Notice in my answer I suggested you keep the solution simple by first just trying to update a single row using the PreparedStatement so you understand how to use multiple tokens in the statement?

I then stated that I had never used a batch updated before.

So if in fact it does make a difference to invoke the "prepareStatement(...)" method outside of the loop it would have been nice for you to respond to my answer stating that the token replacement worked fine but that the "prepareStatement(...)" needs to be outside the loop when using batch processing.

This way you show me that you actually read my answer and tried it.

Also, you are not contributing to the forum because I learned something new and others who read the answer in the other forum will also learn something new.

Again, the point of a forum is to provide feedback, not just ignore answers.
Already asked and answered hours ago: https://stackoverflow.com/questions/52671116/updating-mysql-table-using-where-parameter-from-jtable-cell/52672310#52672310

In fact the same answer was given there before you even posted the question here.

This is why we get so frustrated when you cross post the same question:

1. You don't even take the time to read the answers on the other forums.
2. You don't even take the time to let people know the problem has been solved.

Thank You for suggestion, tried that but still same error.



So then you still haven't told us the statement that is causing the problem!!! How do you expect us to help?

I noticed that everything is executed twice



So you have a bug in your code somewhere. Time to do some debugging.
3 weeks ago
There is no need to clear the table before resetting the model, unless of course maybe you have some TableModelListeners or other custom code that you added to the table.

If you want to change the data in a table all you need is:



So get rid of the



and see what happens.
4 weeks ago
Well we have no idea which statement is causing the Exception, so how do you expect us to help?

I'm guessing the problem is with the DBUtils, since that would appear to be the only code that using indexes.

If so, the I would expect the problem is with your SQL and you are returning an empty ResultSet.

I would suggest you use Prepared Statements when using SQL as it makes the SQL easier to code and you are less likely to make an SQL mistake. Read the tutorial on Using Prepared Statements for more information and examples.
4 weeks ago

Would it be ok to use your code in that? 



That's fine. The "About" page of the blog addresses this in more detail.

but I will be looking for clues as to what I should be doing.



The code in the class is for more fancy features. I would suggest you simply start by looking at the removeColumn(...) method to start with the basics.
1 month ago
You use the removeColumn(...) method of the TableColumnManager. The column is removed from the view, but the data is still in the TableModel.

You can also check out Table Column Manager for a class that will track removed columns and attempt to insert them back in the same place if you ever want to make them visible again.
1 month ago
Why do you have all that extra code? Did you try what I posted?

The point of invoking super.getListCellRenderer(..) is that it will set all the defaults of the renderer.

You then have a simple if condition to override the text in your special case.

1 month ago
Shouldn't be the cause of your problem, but don't extend JComboBox. You only extend a class to add new functionality. Adding data or setting properties is not adding new functionality.

A renderer is shared by all items. I don't see where you ever set the text of the label when you add a String to the combo box. Not sure if this causes the problem or not.

I would suggest you extend BasicComboBox as it will set all the properties of the renderer and then simply invoke toString() on any object you add to the combo box to get the text to display. Then you can check if a Grade object has been added and reset the text.

So the basic logic might be something like:



Also, note that when you use a custom renderer you will break the functionality of the combo box since selection of an item from the combo box using the keyboard will not work. In this case it will not be a big issue since all your items start with the same string.

Note: you could just simply implement the toString() method of your Grade class to return the grade and then you don't need a custom renderer. Although many people will say you should use the toString() method as data for your application.


But for future reference you may want to check out Combo Box With Custom Renderer for a more complete solution.

If you need more help then post a SSCCE that demonstrates the problem.
1 month ago