• Post Reply Bookmark Topic Watch Topic
  • New Topic

use an jcombobox from jframt to another class java  RSS feed

 
wafa khan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
i have a jframe when i have a jcombobox contains databases and i click on button
so i want pass or use this jcombobox in another classe java
because i want to some queries in this class so i need connection to database and database is the item selected from the jcombobox
i do like this
in jframe in begining i write this code :

and in Actionlistener of button i do this:


then in the other classe i do that

But they tell me that any database founded means the variable that i pass from jframe to class java dosen't work
what can i do
help me please
thank you

 
Tony Docherty
Bartender
Posts: 3264
81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But they tell me that any database founded means the variable that i pass from jframe to class java dosen't work

Who tells you this and what does "any database founded" mean?

Have you tried printing out the value of 'db' just before making the connection to see if it contains what you think it does?
 
wafa khan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it gives me nothing
 
Tony Docherty
Bartender
Posts: 3264
81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wafa khan wrote:Yes it gives me nothing

Ok so assuming 'db' is being given the correct value from the combobox (have you printed it out here to see it is given a valid value?) it suggests you aren't passing the String reference as you think you are. But without seeing more code it's hard to tell what is happening.
 
wafa khan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have this code in actionperformed of button

and in begining of jframa i declared this


then in other classe i use the variable db normaly
but it gives me nothing
How can i use the items in comobobox in another classes java
 
Tony Docherty
Bartender
Posts: 3264
81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say you are using it normally what do you mean by that?
 
wafa khan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normaly .. means i use it to get connexion to database that i select in combobox in the jframe


 
Tony Docherty
Bartender
Posts: 3264
81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said before without seeing more code it's not possible to say what is happening. Can you show the code where you pass the db value to the other class and the code in that class which handles the value being passed in.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!