• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using jComboBox with Integers  RSS feed

 
Patrick Evans
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
I was doing it correctly apart from i forgot to change the static Baudrate (9600) to the int.



Thanks
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!