frame.setResizable(true);

HI.....

as disable, maximize button?


void setup()
{
    size(100,100);
    frame.setResizable(true); 
}


void draw()
{
    background(2);


}

boolean a=true;

public void mousePressed()
{

  if(a)
    frame.setSize(623,523) ;
  else
      frame.setSize(123,323) ;
a=!a;


}
Tagged:

Answers

  • Do you mean that you want to make a maximize button as well?

  • Do you mean that you want to make a maximize button as well?

    no. button just want to disable it, because to apply this frame.setResizable (true), the button is enabled.

    if I put in false, frame.setResizable (false) disables the button is, but it does not work well the GUI

  • Sorry, but I don't quite get your English. I'm trying my best, though. The way I understand it is that when you set frame.setResizable() to false, it doesn't do it properly. Do I understand that correctly? If not, tell me what you want to disable.

  • as disable, maximize button?

  • Oh hang on a second. You want to disable the maximize button, while still being able to resize the screen. Is that what you're after?

  • anna ¿¿ :)]

  • @anna2013 was a spam account that has been deleted.

  • edited October 2013

    Regardless of whether you want to make the button hidden, or just to stop it from working, it requires complex knowledge of JInternalFrame, with which I cannot help you with.

    You can however, perhaps re-ask the question, asking how to make use of this: JInternalFrame.setMaximizable(false), and hopefully someone will help you out with this.

    Believe me, I'd help out if I had the ability to, but I don't.

    Best of luck.

    -- MenteCode

  • :o3 LOL

    then what is the function to maximize button???

    for example, exit button, the function is void exit () {}.

    void draw(){
    
    
    }
    
    
    
    
     void exit () {
    
     println("HI_MenteCode");
     }
    
  • About that, vk, that's not quite what he's looking for. He wants the realizability, but he does not want the sketch to maximize, so setting frame.setResizable to false, won't work. In addition to that, setting it to false, once you try the setSize function, it resizes the window, but doesn't resize the sketch.

  • And to answer your question, Omnimusha, just because exit() exists, doesn't mean that there's a function for every button.

    But before you go any further, I've searched a bit more, a found something that might help. Just wait a bit so I can experiment.

  • when you have "overridden" the exit function: void exit () {

         println("HI_MenteCode");
     }
    

    you have actually now broken the processing code. Now your sketches will not exit with the exit() method.

    Also documentation of exit() doesn't say that it is called WHEN the sketch is exiting. It only says to call it TO exit the sketch.

    You cannot be sure that exit() is called EVERY time sketch is stopping. It may be called sometimes. But there's no guarantee.

    There's also a whole discussion on the case of stoping sketch:

    http://forum.processing.org/one/topic/run-code-on-exit.html

    But coming back to your question of removing maximize button: it seems to little juice for too much of a squeeze. What's wrong with having maximize button if you're ok to resize the sketch? Another issue is that: i am not sure that sketches will run well if you resize them? Has anyone worked enough with resizable sketches?

  • edited October 2013

    I myself have worked quite a bit with resizeable sketches, and the only problem I've seen with resizing a sketch is that it won't update while dragging the edges. I can go into further detail, but that's not necessary.

  • edited October 2013 Answer ✓

    Now, back to the question? I have not figured out a way to make this seamless yet, but you can use these lines of code in void draw():

    if(frame.getExtendedState() == 6) {
         frame.setExtendedState(0);
       }
    

    I'm still experimenting, though. Don't you worry.

  • But is sketch restarted when it is resized?

    And when it enlarged by resizing: is it that the image is simply stretched (and sketch.width and height are still from the original size)? or do these parameters change?

  • If you look in the others answers, not the marked, there is some codes, but is said that this is not possible with a jFrame only with a jDialog there are some codes there, but not for processing.

  • But is sketch restarted when it is resized?

    During the resizing of the sketch window, the sketch itself is just paused. Then, when you let go, it will continue from there.

    And when it enlarged by resizing: is it that the image is simply stretched (and sketch.width and height are still from the original size)? or do these parameters change?

    That entirely depends on the way you code your visual resources. Say, if you had an image that was 400 by 300 pixels. If you write: image(yourImage, x, y), the image will stay the same size as the original image. But, if you write: image(yourImage, x, y, width, height), the image will be resiazed according to the sketch size.

    Unless that's all you want to know, I recommend you make your own post with all your questions on resizing, just so you don't "sabotage" the post.

    -- MenteCode

  • edited October 2013

    LOL 8-}

        PImage I;
    
    void setup()
    {
        size(640,480);
        frame.setResizable(true);
        I=loadImage("http://3.bp.blogspot.com/-Ih3jq9B9kB0/TgDVqqfujgI/AAAAAAAAAUA/xDSDyJ945m8/s1600/bleach+manga+554+555+556.png");
    
    }
    
    
    void draw()
    {
    //  ........................
    //-  experimenting by MenteCode
    //  -----------------
      if(frame.getExtendedState() == 6) {
         frame.setExtendedState(0);
       }
    
    if(a) image(I,0,0,840,480);
    else image(I,0,0,640,480);
    
    }
    
    boolean a=true;
    
    public void mousePressed()
    {
    
      if(a) frame.setSize(640,480) ;
    
      else frame.setSize(840,480) ;
    a=!a;
    
    
      }
    

    ! MenteCode great job. ....... but behaves strangely the gui

  • I'm guessing that after a few tests, you can't close the sketch. In fact you can't do anything in the sketch...

    That's what I meant when I said it wasn't seamless yet. Working on it. ;)

  • I'm guessing that after a few tests...

    Tests = clicks.

  • So, after quite a bit of research, I still haven't found another way of disabling the button, so that's probably the best you can get it.

    Unless you don't mind NOT having the menu bar, and making your own buttons...

    -- MenteCode

  • no problem, I prefer the previous solution.

    from already thank you very much

    Greetings!

  • if you have problems with your gui (the way the app looks) after adding:

    surface.setResizable(false);

    make sure you aren't using OPENGL

    //size(1280, 720, OPENGL);

    size(1280, 720);

Sign In or Register to comment.