DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • My Experiences with Maven in IntelliJ IDEA and NetBeans IDE
  • Hack OpenJDK with NetBeans IDE
  • Spec-Driven Development Renamed an Old Problem; It Didn't Solve It
  • Amazon CodeWhisperer to Q Developer to Kiro: The Rise of Agentic Coding

Trending

  • Building a Software Factory With AI Agents and Workflows
  • AI-Era Cybersecurity, Part 1: Mapping Glasswing, Daybreak, Lightwell and the Tools Racing to Find and Fix Bugs
  • When One Docker Swarm Replica Became Unreachable Over an Overlay Network: A Production Case With Traefik
  • Event-Driven AI Systems With Kafka and Autonomous Agents

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Binding a JTable to Swing Controls in NetBeans IDE

Binding a JTable to Swing Controls in NetBeans IDE

Here is an outline of a scenario that binds Swing controls to columns in a JTable, via the tools that NetBeans IDE provides.

By 
Geertjan Wielenga
·
Feb. 20, 08 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
184.1K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Recently I blogged about the Beans Binding Framework and gave a few brief examples. Questions were asked about how those examples would be achieved in NetBeans IDE, via its tooling, instead of manual coding in the editor. Here is an outline of a scenario that binds Swing controls to columns in a JTable, via the tools that NetBeans IDE provides.

  1. Create the application. Create a new Java Application called "TableBindingDemo". Delete the "Main.java" class that is created for you.
  2. Create the JFrame. Create a JFrame called "CustomerFrame".
  3. Create the JTable. Drag a table from the palette onto the CustomerFrame.
  4. Start the server. Under the Tools menu, choose Java DB Database | Start Server.
  5. Bind the JTable to data. Right-click the table and choose "Table Contents". In the Customizer Dialog, click "Bound" in the "Table Model" tab. Click "Import Data to Form". In the "Import Data to Form" dialog, choose the last one of the three, "vir". Once the connection is made, choose the EMPLOYEE table. Click OK. Close the Customizer Dialog.
  6. Bind the columns to data. Right-click the table and choose Bind | elements. Click the arrow buttons to move the 'firstname' and 'lastname' from the 'Available' list to the 'Selected' list. Click OK.Let's now run the application! Right-click the project and choose Run Project. You should now see the JTable filled with data.
  7. Bind Swing controls to columns in the JTable. Drag and drop two JLabels and two JTextFields onto the JFrame. Remove the text in the JTextFields and change the text of the JLabels to "Name" and "Surname". Right-click the "Name" JTextField and choose Bind | text. In Binding Source, choose jTable1. in Binding Expression, choose selectedElement | firstName. Notice that the Binding Expression is now defined as ${selectedElement.firstname}. Click OK. Do the same for the other JTextField, so that the Binding Expression for the second JTextField is set as ${selectedElement.lastname}. Right-click the project and choose Run Project. You should now see that the JTable is synchronized with the JTextFields. When you change something in the JTextField, the JTable is updated and vice versa:
  8. Modify the update strategy. Not happy with the way the Swing controls are synchronized? Right-click the JTextField and choose Bind | elements again. Click Advanced. There you can set Update Properties to something different.

I hope this has answered some questions about the tooling that NetBeans IDE provides for the Beans Binding Framework. If not, feel free to leave questions here and I will try to answer them!

 

Integrated development environment Binding (linguistics) NetBeans

Opinions expressed by DZone contributors are their own.

Related

  • My Experiences with Maven in IntelliJ IDEA and NetBeans IDE
  • Hack OpenJDK with NetBeans IDE
  • Spec-Driven Development Renamed an Old Problem; It Didn't Solve It
  • Amazon CodeWhisperer to Q Developer to Kiro: The Rise of Agentic Coding

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook