Slick Forums

Discuss the Slick 2D Library
It is currently Mon May 20, 2013 8:44 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Aug 21, 2012 2:34 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
I basically want a pop up box that the user must agree to. Does this look ok?

Code:
public class WindowPopUp extends PopupWindow {public WindowPopUp(Widget owner, String title, String message) {
      super(owner);
      setTheme("");
      setCloseOnClickedOutside(false);
      setCloseOnEscape(false);

      ResizableFrame frame = new ResizableFrame();
      frame.setTitle(title);
      frame.setTheme("popupwarning");

      DialogLayout dl = new DialogLayout();
      
   

      Label messageLabel = new Label();
      messageLabel.setText(message);

      Button buttonOk = new Button();
      buttonOk.setText("OK");
      buttonOk.addCallback(new Runnable() {
         public void run() {
            closePopup();
         }
      });

      dl.setHorizontalGroup(dl.createSequentialGroup(messageLabel));
      dl.setVerticalGroup(dl.createSequentialGroup(messageLabel));

      dl.setHorizontalGroup(dl.createSequentialGroup().addGroup(dl.createSequentialGroup(messageLabel, buttonOk)));
      dl.setVerticalGroup(dl.createSequentialGroup().addGroup(dl.createSequentialGroup(messageLabel, buttonOk)));

      frame.add(dl);
      add(frame);
      openPopupCentered();

   }}


I call it like this:
Code:
   new WindowPopUp(this, "Warning", "You must restart for 'multiSamples' setting to take effect")


The only other problem is how do I add a image to it?


Last edited by dime on Tue Aug 21, 2012 4:32 am, edited 3 times in total.

Top
 Profile  
 
PostPosted: Tue Aug 21, 2012 4:21 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
my theme looks like this:

Code:
<images file="warning.png" format="RGBA">
      <area name="warning" tiled="false" repeatX="false" repeatY="false" xywh="0,0,30,31"/>
   </images>

   <theme name="popupwarning" ref="resizableframe-title">
      <param name="icon"><image>warning</image></param>      
      <theme name="" ref="*"/>
   </theme>


How do I set the warning image in the GUI?


Top
 Profile  
 
PostPosted: Tue Aug 21, 2012 5:40 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
The best way to add an image is by adding a Widget and set it's theme name to something like "icon".

Then you do this in your theme:
Code:
<theme name="popupwarning" ref="resizableframe">
   <theme name="dialoglayout" ref="dialoglayout">
      <theme name="icon" ref="-defaults">
         <param name="background"><image>warning</image></param>
      </theme>
      <!-- other stuff -->
   </theme>
</theme>

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Tue Aug 21, 2012 7:10 pm 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
thanks, looks good :)

Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group