Jlist not updating

Rated 4.39/5 based on 726 customer reviews

This is a tutorial on connecting to a database in Java; I'll use My SQL in this tutorial, but the same ideas work with Oracle, Sqlite and others.

JDBC isn't part of Swing, but so many people who write Swing programs want to connect to a database that I thought I'd cover it briefly in this tutorial series.

Or maybe you want to clean up resources, or ask the user if he or she really wants to quit? You can also set icons on labels using the same technique -- in fact images will display even large images if you want.

For that reason I decided to cover it in this tutorial series, even though it's not part of Swing. There's just one little gotcha here, which is that deleting a row from a model doesn't automatically refresh the table. Also in this tutorial, how to protect a list from modification and when to use Linked List. While message boxes are enough for many simple situations, if you want to put your own controls in a dialog box, you need the JDialog class.

If you're using a JTable, you might want to be able to select table rows, for instance so that you can delete rows from a popup menu in response to a right mouse click. Dialog boxes are often used to allow the user to customise program settings, but you can use them for all kinds of things.

NB: You'll need to install a database on your own machine, or somewhere accessible to you, if you want to run the code covered in this part of the tutorial.

Of course you'll need to change the settings as appropriate for your database too.

Leave a Reply