This week's book giveaway is in the JDBC and Relational Databases forum.
We're giving away four copies of Murach's MySQL and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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

Using jComboBox with Integers

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I am trying to set some serial port parameters here:



using an actionPerformed:



To set the serial port parameters i need to use Integers instead of strings. So can someone tell me how i turn my string EG:

into Integers for my combo box
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Patrick Evans wrote: So can someone tell me how i turn my string EG:

into Integers for my combo box


Integer#parseInt(String s) is your friend
 
Marshal
Posts: 79019
375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about Integer#valueOf which returns an Integer rather than an int?
 
Patrick Evans
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:

Patrick Evans wrote: So can someone tell me how i turn my string EG:

into Integers for my combo box


Integer#parseInt(String s) is your friend




'Integer#parseInt(String s)' Does appear to be my friend. Can you explain what i am doing wrong here?




 
Patrick Evans
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was doing it correctly apart from i forgot to change the static Baudrate (9600) to the int.



Thanks
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
apart from i forgot to change the static Baudrate (9600) to the int.

- not, never in Java is possible to hold value in proper data type (Date, Double, Icon, Integet, Long ....), then there isn't some reason to "Integer#parseInt(String s) is your friend"

- isn't some reason to use "parseXxx" in Java

- put int/Integer to DefaultComboModel/JComboBox, then ActionListener returns int/Integer

- various formatting is possible in XxxListCellRenderer
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic