Results 1 to 13 of 13
- 09-16-2013, 01:54 AM #1
Member
- Join Date
- Dec 2012
- Posts
- 39
- Rep Power
- 0
Is it possible to convert this Swing/awt GUI into a JSP GUI? If so, how?
Hello all. I'm not quite sure if this is the right forum for this, but I'm kind of at a loss at this point. I'm not sure if the technology recommended to me is really appropriate.
I was on Stack Overflow (Can I Place a Program Written in the Java Programming Language on the Internet in a Way that Others can Run it for Free Without Security Issues? - Stack Overflow) asking about ways to put my text adventure online for free without massive security problems and someone recommended changing my GUI (which currently uses Swing and awt) into a GUI which uses a Java Server Page so I don't have to deploy an applet. I've since been scrambling to find tutorials and resources for how to do that, but it has not proved easy. Does anyone know any way I can swap out Swing and awt components for whatever it is that a JSP page uses to display content (I'm not even sure at this point if I can use the Java programming language to do that or if I need to learn something else)? Thank you so much for your time, a snippet of my current GUI code is shown below for reference:
Java Code:public void init() { //Add the necessary content pane and set the layout. JLayeredPane contentPane = new JLayeredPane(); contentPane.setLayout(null); contentPane.setBackground(Color.DARK_GRAY); //Set the content pane to the layered pane this.setContentPane(contentPane); //Create Wounded Label JLabel title = new JLabel(); title.setText("WOUNDED"); title.setFont(new Font("Courier", Font.BOLD, 48)); title.setVisible(true); contentPane.add(title, new Integer(1)); //Create the TextFeild for user input. userInput = new TextField("", 15); userInput.setText("Enter your choice here"); userInput.addActionListener(this); userInput.setVisible(true); contentPane.add(userInput, new Integer(3)); //Get insets Insets insets = contentPane.getInsets(); Dimension size; //Create the icon for the background label try{ final ImageIcon wallPaper = new ImageIcon(getClass().getResource("/background.jpg")); JLabel background = new JLabel(wallPaper); contentPane.add(background, new Integer(0)); size = background.getSize(); background.setBounds(0, 0, 1200, 1200); } catch (Exception e) { System.out.println("Error, file not found"); } //Create the JTextArea for the display of story. output = new JTextArea(40, 115); scrollPane = new JScrollPane(output); output.setFont(new Font("Courier", Font.PLAIN, 12)); output.setText(story); output.setVisible(true); scrollPane.setVisible(true); contentPane.add(scrollPane, new Integer(3)); //Uses absolute positioning to lay out the components size = title.getPreferredSize(); title.setBounds(insets.left + 500, insets.top + 100, size.width, size.height); size = userInput.getPreferredSize(); userInput.setBounds(insets.left + 530, insets.top + 1000, size.width, size.height); size = output.getSize(); scrollPane.setBounds(insets.left + 200, insets.top + 200, 800, 800); /* //Create the essential choose button to signal that //the program should retrieve user input from userInput. JButton chooseButton = new JButton(); chooseButton.setText("Choose"); chooseButton.addActionListener(this); contentPane.add(chooseButton); */ }
- 09-16-2013, 01:12 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Re: Is it possible to convert this Swing/awt GUI into a JSP GUI? If so, how?
There is no easy way to convert a Swing GUI to an HTML one, in general.
Your is a simple text adventure with only a few parts to the screen, so this wouldn't be too tough, presuming you know the technologies you are planning on using.Please do not ask for code as refusal often offends.
** This space for rent **
- 09-16-2013, 05:44 PM #3
Member
- Join Date
- Dec 2012
- Posts
- 39
- Rep Power
- 0
- 09-16-2013, 05:52 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Re: Is it possible to convert this Swing/awt GUI into a JSP GUI? If so, how?
It's not simple then.
You'll need to learn a framework, either JSP/servlet or some other one.
gimbal2 often recommends Wicket.
But whichever one you were to choose, it's not a short journey.Please do not ask for code as refusal often offends.
** This space for rent **
- 09-16-2013, 06:02 PM #5
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: Is it possible to convert this Swing/awt GUI into a JSP GUI? If so, how?
Wicket, Play framework, Grails (although that's Groovy and not Java) - all excellent choices.
Note that I consider Servlet / JSP to be a "no framework" solution since it does absolutely nothing for you :) As a first introduction into the world of Java web programming, that's not a bad thing. I consider learning Servlets before any web framework as important as learning Java programming on the command prompt before using an IDE.
On that note:
Free Online Version of Core Servlets and JavaServer Pages (Second Edition) in PDF"Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 09-16-2013, 06:07 PM #6
Member
- Join Date
- Dec 2012
- Posts
- 39
- Rep Power
- 0
Re: Is it possible to convert this Swing/awt GUI into a JSP GUI? If so, how?
- 09-16-2013, 06:48 PM #7
Re: Is it possible to convert this Swing/awt GUI into a JSP GUI? If so, how?
Why do you want to do this in the first place? Just package your game as an applet, webstart, and application, and then let people deploy it however they want. Seems like a ton of overkill to learn JavaEE just to convert an existing game to something more "webby".
How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
- 09-16-2013, 07:06 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
- 09-16-2013, 07:44 PM #9
Member
- Join Date
- Dec 2012
- Posts
- 39
- Rep Power
- 0
Re: Is it possible to convert this Swing/awt GUI into a JSP GUI? If so, how?
So, here's the problem. I'm trying to get this game promoted on a website that will not promote file downloads unless they're super-duper secure, and there doesn't seem to be a way for an indie developer to get that sort of recognition if it's the first program they've put out.
I tried putting it on a website and deploying it as an applet (http://firstprinceproductions.helioh...g/Wounded.html), but when people go to the page with a modern browser they get a scary warning message telling them what horribly insecure things applets are. I guess I could try to re-submit that game as a link to an applet, but I imagine I'll just get rejected before anyone actually plays my game, again.
This game wasn't a java game to start actually, it was a C++ game. I've already learned another programming language to try and get people to actually be willing to play it. Now I'm starting to wonder whether I should have just tried to learn flash and done the whole thing there, as it seems to be the technology of choice for online games. Still, I made my stupid, stupid decision and now I have to live with ~5000 lines of code no one wants to run.
- 09-16-2013, 07:51 PM #10
Re: Is it possible to convert this Swing/awt GUI into a JSP GUI? If so, how?
Well, don't panic just yet. Firstly, you're in good company. Plenty of people make plenty of games in Java: Showcase - Java-Gaming.org
There are more options other than deploying as an applet. Have you thought about deploying as a webstart application? Or a runnable jar? Or even a packaged executable?
It's true that applets are rather un-pretty with Java's new warnings all over the place, but I really doubt the solution to your problem will be starting over with JSP.
Where are you trying to promote your game? You might even consider going for a different host- Game Jolt allows applets (I think), and I even offer free Java hosting (although you admittedly won't magically get a million views without doing your own promotion) at StaticVoidGames.com.
I'd recommend checking out the games at JGO and seeing how they're doing deployment, consider deploying as a webstart or runnable jar, or maybe just using a different site with less arbitrary rules.How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
- 09-16-2013, 08:44 PM #11
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: Is it possible to convert this Swing/awt GUI into a JSP GUI? If so, how?
Are my posts invisible again? Darnit!
By the way I have to mention a huge disadvantage regarding Java web development: good luck hosting that stuff somewhere. I can name literally one in the Netherlands, as apposed to the 250 PHP hosting services (as an example). If you go down that route you may even consider forfeiting Java entirely and go for a *gulp* HTML 5 type of solution. I can't believe I recommended that.Last edited by gimbal2; 09-16-2013 at 08:52 PM.
"Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 09-16-2013, 11:23 PM #12
Member
- Join Date
- Dec 2012
- Posts
- 39
- Rep Power
- 0
- 09-17-2013, 03:54 PM #13
Re: Is it possible to convert this Swing/awt GUI into a JSP GUI? If so, how?
Thanks! It's definitely still a work in progress, but we've come a long way. I'm currently working on a huge overhaul, rewriting everything from scratch.
Each member can set the source permissions for their own games, so the short answer is that it depends. When in doubt, leave a comment on a game you're interested in and ask permission!How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
Similar Threads
-
Convert applet from AWT to Swing
By willp in forum New To JavaReplies: 9Last Post: 09-04-2012, 01:08 AM -
Convert THE APPLET CODE TO SWING USING JPANEL
By jammyjamsticy in forum AWT / SwingReplies: 2Last Post: 12-22-2011, 10:16 AM -
how to convert SWING GUI into exe format
By santhosh_el in forum AWT / SwingReplies: 7Last Post: 04-04-2009, 01:36 PM -
how to convert xml to xsd
By adi in forum XMLReplies: 2Last Post: 02-12-2009, 03:43 PM -
map javax.swing.text.Element to javax.swing.text.View
By elizabeth in forum New To JavaReplies: 1Last Post: 07-30-2007, 08:02 PM
Bookmarks