1
\$\begingroup\$

I recently started using slick2D in my gaming programs and a problem I have is not having the ability to remove the border/titlebar. I usually do this to create my own cutom look/ interface but if I try:

this.setUndecorated(true);

It doesnt work.

How do you acheive this?

\$\endgroup\$
3
  • \$\begingroup\$ Did you try setundecorated(true)?? \$\endgroup\$ Commented Mar 26, 2013 at 2:41
  • \$\begingroup\$ sorry i meant to write true @Savlon but where do i put this? \$\endgroup\$ Commented Mar 26, 2013 at 3:07
  • 1
    \$\begingroup\$ I believe this has to be set before the window is created. So you'll need to create a launcher or somehow relaunch the existing window. \$\endgroup\$ Commented Mar 26, 2013 at 4:14

2 Answers 2

3
\$\begingroup\$

Ok so here is a basic application that has the title bar removed

public static void main(String[] args){
    JFrame frame = new JFrame("Without Title Bar Frame");
    frame.setUndecorated(true);
    frame.setSize(400,400);
    frame.setVisible(true);
  }

Paste the above code into a java class

Also be sure to import

import javax.swing.JFrame;

You see how frame.setUndecorated(true); is straight after the instantiation of the frame? Place yours in the same place and you will have no issue at all :)

EDIT: here is what I found which may work.

http://slick.javaunlimited.net/viewtopic.php?f=3&t=4978

http://codebrocken.blogspot.com.au/2012/03/java-creating-undecorated-window-with.html?m=1

But as it states in that post it isn't support yet.

\$\endgroup\$
4
  • \$\begingroup\$ this would work if i wasnt using slick2D but I am so it won't work because I'm not creating a JFrame \$\endgroup\$ Commented Mar 26, 2013 at 20:19
  • \$\begingroup\$ Hmm I see... So you are using Display to create your window? You can't create a full screen app? Have the surrounding areas of your window black? I'm not sure if Display has a setUndecorated method.. You may have to look through the slick2D API \$\endgroup\$ Commented Mar 27, 2013 at 1:33
  • \$\begingroup\$ i can create a full screen app (I just need to change false to true in this code : "app.setDisplayMode(FRAME_WIDTH, FRAME_HEIGHT, false);" \$\endgroup\$ Commented Mar 27, 2013 at 3:34
  • \$\begingroup\$ I found something that may work... Check my answer again \$\endgroup\$ Commented Mar 27, 2013 at 4:21
0
\$\begingroup\$

Originally I was using

AppGameContainer app = new AppGameContainer(new Game());

to create my game. However I wanted to set the frame to be undecorated. So I searched around and found that if you changed

AppGameContainer app = new AppGameContainer(new WizardGame());

to

CanvasGameContainerapp = new CanvasGameContainer(new Game());

so that its now a canvas and then add it to a JFrame and set that JFrame to undecorated, you would get a undecorated slick2D program.

CODE:

public static void main(String[] args) throws SlickException {
    JFrame frame = new JFrame();
    CanvasGameContainer app = new CanvasGameContainer(new Game());
    frame.setUndecorated(true);
    frame.setVisible(true);
    frame.add(app);
    frame.setSize(500, 500);
    app.start();
}

The only problem that i have with it is that i have to click it once to render the images. If i don't it just has a black screen. This could be because of my other code but I don't think it should happen for anyone else.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.