Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  AWT + BufferStrategy  (Read 1518 times)
0 Members and 1 Guest are viewing this topic.
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Posted 2004-01-19 19:38:34 »

Anyone here know how to get the size of the titlebar and borders of a JFrame? my game worked great till i decided i want to put an AWT MenuBar in there. adding the menuBar to my render method causes it to vanish up behond the game's title bar. If i knew how to get the offset between the window's edge and the usable part (as far as the AWT's concerned), having it in the render loop would work.

Since on a diferent platform or even if someone's got a diferent theme there's always a diferent sized title bar, hard-coding a value just won't work
Offline Abuse

JGO Ninja


Medals: 60


falling into the abyss of reality


« Reply #1 - Posted 2004-01-19 20:00:33 »

[J]Frame.getInsets(). (inherited from Container)

note.
Only returns an accurate value once the Frame has been made displayable.
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #2 - Posted 2004-01-19 20:03:34 »

There is a proper way to do that... however I always just overwrite getPrefferedSize and getMinimumSize and let the LayoutManager figure out what to do Smiley

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public class Blabla extends Canvas
[...]
public Dimension getPreferredSize()
      {
            return new Dimension(WIDTH,HEIGHT);
      }
      public Dimension getMinimumSize()
      {
            return new Dimension(WIDTH,HEIGHT);
      }
[...]
}


edit: heh... I told you there is a proper way Grin

弾幕 ☆ @mahonnaiseblog
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #3 - Posted 2004-01-19 20:13:18 »

has anyone done this before? it would be good if there were some examples out there i could look at. using translate, the menu bar shows in the right place but (argh!) the menu items don't show up at all. i thought menuBar's paintChildren() would have included any open menus.

really if it's possible i'd just paint the whole contentPane but the thing paints a background regardless of setOpaque. is there another component that wont paint over the background?

edit: is a menu item even a child of the contentPane?
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #4 - Posted 2004-01-19 21:13:24 »

ok, just trial and error, got it working very nicely by painting the LayeredPane instead of the RootPane. i had to use a custom ContentPane that doesn't paint it's background.

to answer my own question, menubars seem to be a child of LayeredPane.

the result: Functional swing drawn onto a bufferStrategy. Hooray!

it did some really wierd things when i changed the windows font size back from extra large. the start menu stayed huge, the game itself actually changed back ok on the fly (no idea how, i was expecting the file menu to be hanging down a bit... wierd) then only after closing the game did the start menu go back to normal.

Must be some DirectX bug?
Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (110 views)
2017-09-30 02:57:34

theagentd (136 views)
2017-09-26 18:23:31

cybrmynd (245 views)
2017-08-02 12:28:51

cybrmynd (241 views)
2017-08-02 12:19:43

cybrmynd (240 views)
2017-08-02 12:18:09

Sralse (254 views)
2017-07-25 17:13:48

Archive (864 views)
2017-04-27 17:45:51

buddyBro (1008 views)
2017-04-05 03:38:00

CopyableCougar4 (1569 views)
2017-03-24 15:39:42

theagentd (1373 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!