Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 4th, 2012, 12:56 PM
TheAlmighty TheAlmighty is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 TheAlmighty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 45 m 53 sec
Reputation Power: 0
Need some help please

Code:
if(main.equals("Start")) {
 Object[] topics{"Random","Sports","Geography","Politics","History"}; 
String topic=(String)JOptionPane.showInputDialog(null,"Choose a topic:","Topics",JOptionPane.QUESTION_MESSAGE, null, topics,topics[1]); 

new Thread(){ 
public void run() {
 .main(new String[]{});}
 }.start();


This is a part of a code for a quiz that I am doing, this is supposed to run an external file with the questions for each topic. The only little thing that i need to add here is the file name right before main.
Code:
.main(new String[]{});}


My question is; How do I make on of the objects in "topics" to register into the .main part?
For example:
I choose the Sports topic
that means I want
Code:
Sports.main(new String[]{});}

to be executed.

I still cannot figure this out, which I have been trying to do for the past 4 hours

Any help appreciated

Reply With Quote
  #2  
Old November 5th, 2012, 08:35 AM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 51 m 13 sec
Reputation Power: 345
The variable topics is defined inside an if statement and is only known there.
Can you define it at the class level so all methods can see it?

It would help if you posted a small, complete program for testing. The bits and pieces you posted make it hard to see what you are trying to do.

Reply With Quote
  #3  
Old November 5th, 2012, 02:51 PM
TheAlmighty TheAlmighty is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 TheAlmighty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 45 m 53 sec
Reputation Power: 0
I solved the problem by using buffered reader and reading from an .txt file instead . This can be closed now.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Need some help please

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap