A multi-line editbox may be the best choice for displaying text. Example:
%# read text file lines as cell array of strings fid = fopen( fullfile(matlabroot,'license.txt') ); str = textscan(fid, '%s', 'Delimiter','\n'); str = str{1}; fclose(fid); %# GUI with multi-line editbox hFig = figure('Menubar','none', 'Toolbar','none'); hPan = uipanel(hFig, 'Title','Display window', ... 'Units','normalized', 'Position',[0.05 0.05 0.9 0.9]); hEdit = uicontrol(hPan, 'Style','edit', 'FontSize',9, ... 'Min',0, 'Max',2, 'HorizontalAlignment','left', ... 'Units','normalized', 'Position',[0 0 1 1], ... 'String',str); %# enable horizontal scrolling jEdit = findjobj(hEdit); jEditbox = jEdit.getViewport().getComponent(0); jEditbox.setWrapping(false); %# turn off word-wrapping jEditbox.setEditable(false); %# non-editable set(jEdit,'HorizontalScrollBarPolicy',30); %# HORIZONTAL_SCROLLBAR_AS_NEEDED %# maintain horizontal scrollbar policy which reverts back on component resize hjEdit = handle(jEdit,'CallbackProperties'); set(hjEdit, 'ComponentResizedCallback',... 'set(gcbo,''HorizontalScrollBarPolicy'',30)')
To enable horizontal scrolling, we need to get a handle to the built-in jScrollPane java component. I use the excellent FINDJOBJ function. Then we set the HorizontalScrollBarPolicy property to javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED (= 30) as described in this post . I also turned off text editing (read-only).
