📄 scrolldemo.m
字号:
function scrollDemo()
% By junziyang
% Thanks nostalgica
% 01/13/2005
import javax.swing.*
import java.awt.*
% Creat a MATLAB figure
fig =figure('MenuBar','none','Position',[300,300,500,200],'Resize','off');
% Add a JPanel to the figure
[Jpanel, Hpanel]=javacomponent(JPanel,[0,0,500,200],fig);
Jpanel.setLayout(BorderLayout);
% Creat a JScrollBar
scrollBar = JScrollBar(0,1,1,0,255);
% Add the scrollbar to the panel
Jpanel.add(scrollBar,BorderLayout.SOUTH);
% Creat a handle structure
handles.scrollBar = scrollBar;
handles.Jpanel = Jpanel;
% Set the callback of the UI
set(Jpanel,'MouseEnteredCallback',{@mouseEnteredCallback,handles});
set(Jpanel,'MouseExitedCallback',{@mouseExitedCallback,handles});
% Activite the scrollbar callback function as the mouse entered
function mouseEnteredCallback(hObject,eventdata,handles)
handles.scrollBar.setFocusable(true);
set(handles.scrollBar,'MouseWheelMovedCallback',{@scroll,handles});
drawnow %刷新之后才能获得焦点
handles.scrollBar.requestFocus;
function mouseExitedCallback(hObject,eventdata,handles)
handles.scrollBar.setFocusable(false);
% Mouse whell moved callback function
function scroll(hObject,eventdata,handles)
data =get(hObject,'MouseWheelMovedCallbackData');
switch data.wheelRotation
case 1
set(hObject,'value',min(get(hObject,'value')+1,get(hObject,'Maximum')));
case -1
set(hObject,'value',max(get(hObject,'value')-1,get(hObject,'Minimum')));
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -