how to refresh the view [message #465984] |
Wed, 28 December 2005 05:13 |
Eclipse User |
|
|
|
Originally posted by: xiuli_xu.126.com
I create a jbutton in the viewpart, want to display jtable when clicking
the jbutton, but the jtable cannot display immediately. I must resize the
view to enforce a refresh.
How to refresh the view in the code?
the code:
public void createPartControl(Composite parent) {
// TODO Auto-generated method stub
parent.setLayout(new GridLayout(1,true));
parent.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite composite = new Composite(parent, SWT.EMBEDDED);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight=0;
layout.marginWidth=0;
layout.horizontalSpacing=0;
layout.verticalSpacing=0;
GridData gridData = new GridData(GridData.FILL_BOTH);
composite.setLayout(layout);
composite.setLayoutData(gridData);
mFrame = SWT_AWT.new_Frame(composite);
final Panel contentPanel = new Panel();
contentPanel.setLayout(new BorderLayout());
JButton jbutton = new JButton();
contentPanel.add(jbutton,BorderLayout.NORTH);
jbutton.setText("Show JTable");
jbutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
System.out.println("button clicked");
// TODO Auto-generated method stub
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices =
env.getScreenDevices();
// REMIND : Multi-monitor full-screen mode
not yet supported
for (int i = 0; i < 1 /* devices.length
*/; i++) {
DisplayModeTest test = new
DisplayModeTest(devices[i]);
contentPanel.add(test,BorderLayout.CENTER);
test.initComponents();
test.begin();
}
}
});
mFrame.add(contentPanel);
}
|
|
|
|
|
|
Re: how to refresh the view [message #466025 is a reply to message #466023] |
Thu, 29 December 2005 05:50 |
Eclipse User |
|
|
|
Originally posted by: xiuli_xu.126.com
I have tried the layout() method, do not work.
In my code, a swing control jtable is added in a SWT composite, I called
the SWT composite.layout(), didn't refresh. I called the jtable's
parent,JPanel's layout() method, the view refreshed, but the jtable did
not display still. It seems there's something strange between the Swing
and SWT control communication.
now I try to use the OS.RedrawWindow method to redraw the window, but
still not work. maybe the arguments of RedrawWindow method are wrong. do
you have any idea?
the code is:
Shell shell = Display.getDefault().getActiveShell();
int handle = OS.GetActiveWindow();
Rectangle r = shell.getClientArea();
RECT rect = new RECT();
OS.GetClientRect (handle, rect);
OS.RedrawWindow(handle,rect,0,OS.RDW_ERASE | OS.RDW_FRAME |
OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN);
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03141 seconds