Old to new, basic question.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Old to new, basic question.

  1. #1
    Join Date
    Aug 2004
    Posts
    5

    Old to new, basic question.

    I haven't used Java in years, now after installing a copy of Microsoft's Visual J# 2005 and importing some old code to a project (written back in 1.4) I've come up with a number of errors and of course syntax appears to have changed over the years. I intend to go ahead and port it to the newer version of Java and could use some syntax referances. Additionally One warning comes up recurringly upon debug. "Switch statement contains no 'default'"

    for example
    Code:
    public gameFrame(int server, int mode) {
    		
    		super(" game ("+windowcount+")");
    		windowcount++;
    
    		p = new gamePanel(this, "file:/"+System.getProperty("user.dir")+System.getProperty("file.separator"), false, server, null);
    
    		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    
    		int tx = d.width/2-320;
    		int ty = d.height/2-240;
    
    		if (tx<0)
    			tx=0;
    		if (ty<0)
    			ty=0;
    
    		switch (mode) {
    			case 0:
    				w = new Window(this);
    				w.add("Center", p);
    				w.resize(640,480);
    
    				w.move(tx,ty);
    				move(tx,ty);
    
    				w.show();
    				p.start();
    				show();
    				
    				break;
    			case 1:
    				add("Center",p);
    				//resize(586,441);
    				move(tx,ty);
    				show();
    				fullscreen=false;
    				p.resize(640,480);
    				pack();
    				p.start();
    		}
    		setIconImage(p.GetImage("gameicon.gif"));
    }
    Do you now have to declare a default value for switch statements and if so what's the syntax for doing so?
    Last edited by Hack; 12-12-2007 at 10:18 AM. Reason: Added Code Tags

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Does this help?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    I don't know that I would call using J# "using Java".

    Was the message you received (no default for switch) an error or a warning? While it is good practice to include a default, and I can't imagine not doing so, I do not expect the compiler to refuse to compile a switch structure that does not include a default condition.

  4. #4
    Join Date
    Sep 2005
    Location
    istanbul / Turkey
    Posts
    133
    J# is not an option to develop java applications, are you migrating into .NET ?

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Quote Originally Posted by mr1yh1
    J# is not an option to develop java applications
    Why not?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  6. #6
    Join Date
    Sep 2005
    Location
    istanbul / Turkey
    Posts
    133
    - J# is not compiled into java byte-code but .NET's MSIL.
    - J# does not implement whole java-2 class libraries,
    there is not any guarantee (and any reason such a guarantee)
    for completeness or compatibility,
    since microsoft does not target any java virtual machine.

  7. #7
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Quote Originally Posted by mr1yh1
    - J# is not compiled into java byte-code but .NET's MSIL.
    - J# does not implement whole java-2 class libraries,
    there is not any guarantee (and any reason such a guarantee)
    for completeness or compatibility,
    since microsoft does not target any java virtual machine.
    Ah...Ok. Thanks.

    Then what would you use J# for?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  8. #8
    Join Date
    Mar 2007
    Location
    Bangalore, India
    Posts
    247
    J# can be used when you want to develop Windows applications using Java language without the Java framework and without byte code. You can either get the end product as either as an exe or the .Net MSIL. It can be used instead of VB.Net or C#.Net basically, or to complement / supplement code written in these languages with Java. The only thing (I believe) that is common to Java and J# is the language syntax and some of the libraries.

  9. #9
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Thanks for the explanation.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Replies: 2
    Last Post: 04-12-2005, 05:46 PM
  2. A more basic question
    By crypto85 in forum .NET
    Replies: 4
    Last Post: 02-18-2005, 08:15 PM
  3. SQL and Visual Basic question.
    By Bob in forum VB Classic
    Replies: 2
    Last Post: 11-19-2002, 10:56 PM
  4. SQL Server 2000 and Visual Basic Question
    By Eric Harris in forum VB Classic
    Replies: 2
    Last Post: 04-21-2002, 02:03 PM
  5. Re: Editorial by Russell Jones/Attack on Gosub
    By Dan Barclay in forum .NET
    Replies: 90
    Last Post: 03-09-2001, 08:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center