2

I have created a MATLAB GUI, which I would like to display so that it fills the whole screen. Currently, the titlebar is showing at the very top. Is there a way to hide this titlebar?

I considered using the psychtoolbox for this purpose, which allows for full screen displays, but this doesn't allow for standard MATLAB GUI elements to be included as I understand it.

(If it is of importance, this is for OSX. I would obviously hide the menubar before making the GUI fullscreen.)

Bill Cheatham
  • 11,396
  • 17
  • 69
  • 104

1 Answers1

6

I don't know if this will work for OSX, but on Windows I was able to use the Java code from this MATLAB newsgroup thread to create a full screen window with no title, edges, etc. and display an image in the middle. Here's how I made the window:

img = imread('peppers.png');  %# A sample image to display
jimg = im2java(img);
frame = javax.swing.JFrame;
frame.setUndecorated(true);
icon = javax.swing.ImageIcon(jimg);
label = javax.swing.JLabel(icon);
frame.getContentPane.add(label);
frame.pack;
screenSize = get(0,'ScreenSize');  %# Get the screen size from the root object
frame.setSize(screenSize(3),screenSize(4));
frame.setLocation(0,0);
frame.show;

And you can hide the frame again by doing this:

frame.hide;

Not sure how this would work in general for displaying a typical MATLAB GUI. I'll have to play around with it more and find out.

gnovice
  • 125,304
  • 15
  • 256
  • 359
  • 1
    Excellent! Your solution works on OSX. I tried to use `setUndecorated` on a figure window, but it turns out that once the window is generated, setUndecorated won't make the title bar disappear, i.e. you have to modify the property before showing the frame - which only seems to be possible by your approach. – Jonas May 23 '11 at 17:28
  • @Jonas: Yeah, one of the first things I tried was to modify an existing window, which unfortunately doesn't work. Now I'm trying to see if I can add GUI elements to the frame I created. – gnovice May 23 '11 at 17:34
  • @gnovice, thanks, your solution worked great and I extended it to include multiple monitors setup using the result from get(0,'monitorpositions') command. This solution looks like using java (JVM) commands to do the work rather than native matlab commands, which is nice. However I would like to extend this to include outputting some text at a given position on the frame created above and also to update the image dynamically at runtime based on user input via kyeboard. I tried using java text field and adding it to the frame created above, but it didnt work. – user1524182 Jul 13 '12 at 17:13
  • Great solution! I need now a help to make 'ginput' or similar function work. How can I do? – SPS Feb 05 '16 at 17:51
  • No one could me help? Because solution presented here to show an image full screen is perfect, now I'm looking for a method to get pixel positions of points on that full screen image. The problem is that 'ginput' open another figure on Matlab. How to solve? – SPS Feb 08 '16 at 11:11
  • @SPS: The problem is that `ginput` is designed to work with [MATLAB handle graphics](http://www.mathworks.com/help/matlab/learn_matlab/understanding-handle-graphics-objects.html), whereas the above solution bypasses those and uses Java objects instead. You will likely have to search for a Java-based solution instead of the `ginput` function. – gnovice Feb 08 '16 at 18:30
  • @gnovice I've understood this but I'm not practical with Java. Could you or someone else suggest any relative easy documentation? Which command to use with Java, using Matlab to substitute 'ginput'? – SPS Feb 11 '16 at 15:51