Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


This may counts as a Java internal bug, or a glitch in programming...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 tom_mai78101   Members   -  Reputation: 575

Like
0Likes
Like

Posted 17 February 2012 - 08:25 AM

Here I present to you a Java bug I recently found while watching Mojang livestream their MoJam for Humble Bundle.

The following two pictures are shown below. The highlighted part of the code are the only lines that are changed.

Picture 1 (Exhibit A):

Posted Image

Picture 2 (Exhibit B):

Posted Image


====================================================================================

In Picture 1, at lines 103 and 104, when the JFrame first starts to become visible, and then disable resizing, it causes a bug in JFrame.pack() method and display an inaccurate size of the JFrame's border size.

However, in Picture 2, when lines 103 and 104 are switched around, everything is correctly displayed.

So, what should I do about this? Should I report this or just leave it, as I have fixed it by using the solution in Picture 2? Thanks for viewing.

Sponsor:

#2 Antheus   Members   -  Reputation: 2397

Like
0Likes
Like

Posted 17 February 2012 - 11:10 AM

JFrame uses whatever default layout manager is, which may interpret dimensions differently.

Either set a layout manager or just set Game as contentPane.

Layout managers are a pain.

Should I report this or just leave it


Aside from likely not being a bug, Swing was abandoned years ago, only thing still on life support is JavaFX and neither Sun nor Oracle cared about Swing foundation, so IMHO it's not worth reporting it.

#3 tom_mai78101   Members   -  Reputation: 575

Like
0Likes
Like

Posted 18 February 2012 - 12:35 PM

When I set my Game to ContentPane, it creates a thin, black boundary (border) around the inside of the JFrame. How do you make it fill up the entire JFrame (without the borders)?

Or just set JFrame.setResizable() to false, then set JFrame.setVisible() to true?

Looks like I should just use the bugginess as a feature, instead of complaining about it.

#4 Antheus   Members   -  Reputation: 2397

Like
0Likes
Like

Posted 18 February 2012 - 01:11 PM

Absolute sizes are next to impossible to implement correctly. For example, they need to take into account dpi setting of the screen, something which is buggy in just about every OS. There's also problems with aspect ratio. All of these become an issue once fonts are involved.

Swing also abstracts away the crucial API each OS uses to provide such information, but the abstractions aren't enough.

Unless you want to spend most of development trying to tweak around all kinds of inconsistencies, just design UI to be dynamic.

Or make it fixed size, but center it on screen (BorderLayout.CENTER or similar). Trying to match it to outer borders of JFrame is simply not worth it.

#5 tom_mai78101   Members   -  Reputation: 575

Like
0Likes
Like

Posted 19 February 2012 - 01:12 PM

Ok. Thanks for the explanation.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS