Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  JFrames and Resolution...  (Read 1264 times)
0 Members and 1 Guest are viewing this topic.
Offline THEOWL

Senior Newbie

Java games rock!

« Posted 2005-03-02 15:37:02 »

Hi. I am creating a basic board game with JFrames and I have a few questions...

First, I want to set the resolution to 800x600 which I did with a setsize(800, 600). However, if I drag the window, everything gets messed up. Is there a way to solve this?

Also, I thought that one way to solve it might be to change the monitor resolution in the game. Does Java have a easy way of doing this? Thanks!
Offline weston
« Reply #1 - Posted 2005-03-02 15:47:23 »

If you want to change the monitor's resolution, you'll have to switch to fullscreen exclusive mode first. This should give you some useful information:

for(int i = 1; i > 0; i++)
     System.out.println(i+" cups of java downed");
Offline digitprop

Junior Devvie

« Reply #2 - Posted 2005-03-05 15:48:26 »

If dragging the frame messes up the displayed graphics, this indicates a redraw problem. How do you draw and redraw the graphics output?

You should use paint(Graphics g) to do the painting, and you should expect this method to be called each time the window needs to be refreshed.

You should not use getGraphics() outside the paint() method to get a graphics context and draw into it - that is not the way this method is supposed to be used, and it does not work reliably.

Actually, the story is more complex for JFrame. Since this is a container, it is expected to contain child components, and therefore there is a method paintComponents(Graphics g) which must ensure that all child components are painted. If you overwrite paint(Graphics g), you should call super.paint(g) to ensure that the paintComponents(g) method is called, or you should call it directly (the former is cleaner, as you cannot know what else happens in the original paint method).

The best way to have custom content painted is to extend JComponent to have a custom component, and then add this component to the JFrame.

M. Fischer .
Pages: [1]
  ignore  |  Print  

EgonOlsen (45 views)
2018-06-10 19:43:48

EgonOlsen (27 views)
2018-06-10 19:43:44

EgonOlsen (47 views)
2018-06-10 19:43:20

DesertCoockie (210 views)
2018-05-13 18:23:11

nelsongames (127 views)
2018-04-24 18:15:36

nelsongames (126 views)
2018-04-24 18:14:32

ivj94 (867 views)
2018-03-24 14:47:39

ivj94 (128 views)
2018-03-24 14:46:31

ivj94 (779 views)
2018-03-24 14:43:53

Solater (143 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

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 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‑
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!