• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem on setSelectedItem() on my Jcombobox

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi everyone im still learning in java programming and i got problem here to set the selected item on my JCombobox. i have CRUD Form and i got problem when i try to get data JCombobox from my database.

here's my code:

here's my code when i click insert button and my code works fine.

//// Here's my code when i want to get the value from my database and show it to my form when the mouse clicked


can everyone please help me to solve this problem?thanks
Untitled.png
[Thumbnail for Untitled.png]
 
Marshal
Posts: 79151
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I edited your code to add code tags, remove the worst of the long lines and excess blank lines. You should do that infuture: doesn't it look better Also, you should write // before a comment not //////.
Unfortunately you have lots of code to read, and the message in the screenshot is illegible. Please copy and paste the message about that Exception because otherwise we cannot help.

I can see some problems in the code. You are mixing logic and display code in the same class. Don't. Write a class which accesses your database and call its methods from the action listener. Remove the if-elses from the action performed method. If it is necessary to have a different field depending on which radio button is enabled, and use action listeners on the radio buttons to set that field.
Make sure your arrays have the right capacity. If you have a No 7 element in a result set, that means there are at least 7 results, numbered 1‑7. If you have a No 7 element in an array, the array must have at least 8 elements numbered 0‑7.
 
eka satria
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to the Ranch

I edited your code to add code tags, remove the worst of the long lines and excess blank lines. You should do that infuture: doesn't it look better Also, you should write // before a comment not //////.
Unfortunately you have lots of code to read, and the message in the screenshot is illegible. Please copy and paste the message about that Exception because otherwise we cannot help.

I can see some problems in the code. You are mixing logic and display code in the same class. Don't. Write a class which accesses your database and call its methods from the action listener. Remove the if-elses from the action performed method. If it is necessary to have a different field depending on which radio button is enabled, and use action listeners on the radio buttons to set that field.
Make sure your arrays have the right capacity. If you have a No 7 element in a result set, that means there are at least 7 results, numbered 1‑7. If you have a No 7 element in an array, the array must have at least 8 elements numbered 0‑7.



Hi thanks for your help yeah it much better to look now
absolutely i've got problem to get the selected value from JCalendar and Jradiobutton and i wanna start to ask with my Jcombobox thats why i jump my array from 4 to 7 hehe.

here's the error message what i got:

 
eka satria
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ah i already solved the error. the only way i have to do only delete "final Jcombobox" and "Final Jradiobutton" on my script
 
reply
    Bookmark Topic Watch Topic
  • New Topic