Question

I programmed a game in Java Swing using null layout. Except for a few glitches that I'm working on, it is perfectly functional and looks pretty nice. My plan: fix the few bugs, add a few extra features, then use SwingWeb or AjaxSwing to allow my game to run in a web browser using HTML/CSS/JavaScript. But after talking to some people here, I feel concerned that my game will not be displayed properly since I didn't use a layout manager. Exact placement of components works just perfect for the nature of the game, since I need to have my JLabels moving around constantly, and attempting to this with a layout manager would be very problematic - so I would like to avoid changing from my null layout if I possibly can. So before I make a decision about this, can someone explain to me the problems that I could face regarding the null layout if I proceed with my plan as described above? Note that clearly I do not intend the window of the game to be resizable, as it will be running in a browser.

Was it helpful?

Solution

AFAIU null layouts translated to HTML could only result in the position:absolute; style.

That would work even less well in HTML than it would in Swing. HTML is supposed to flow, and once the user starts increasing or decreasing the size of the text in their browser, it would fall apart.

OTHER TIPS

Programming with NULL layout is acceptable when you are not resizing you window or you are not using changeListeners, so avoid using the null layout. Read this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top