Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] side scroller level editor

Started by No_Germs Oct 12, 2005 at 10:13 AM 0 replies 650+ views
Original Post
No_Germs
No_Germs
my game's a classical side scroller- you jump on platfroms, kill enemies. now i've started working on the level editor app. i want the user to be able to drag the platform and resize after placing it, so i've created a class that inherites jComponent, and implements MouseListener, so when the mouse is clicked over the platform you can drag it, and when it is clicked over it's border you can resize it. first of all, is that the correct way to go? secondly, i don't want to rely on a LayoutManager, so i don't useone. i want my component to have it's own fixed size, but even though i've overrided getMaximumSize getMinimumSize getPrefferedSize the component still fills the whole jframe, even after i resize the frame. how do i prevent it? maybe i should create this component from scratch and not inherit JComponrnt?
Epo35
Epo35


Right now you have a default layout with in your JFrame. You have many options with working with layouts. You should look at GridBagLayout().

But for complete freedom, you set the Layout to null then with setbounds you can set the hight, width, x-coor and y-coor of the Component, like a button.

-Example-
setLayout(null); <---This should be set for the Frame or Panel or whatever you use to place your Components on, like buttons..

button.setBounds(x,y,width,height);<------A button or other Components have this method. This will set the width and height of it then the x and y location of it.


http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Component.html#setBounds(int,%20int,%20int,%20int)



by the way. Those will return values and not set affect your layout.
getMaximumSize
getMinimumSize
getPrefferedSize


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.