Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » how to refresh the view
how to refresh the view [message #465984] Wed, 28 December 2005 05:13 Go to next message
Eclipse UserFriend
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 #465986 is a reply to message #465984] Wed, 28 December 2005 08:18 Go to previous messageGo to next message
venkataramana m is currently offline venkataramana mFriend
Messages: 86
Registered: July 2009
Member
How about issuing a layout(..) message on the LayoutMgr installed on the composite holding your JTable ?

Thanks
~Venkat
Re: how to refresh the view [message #466019 is a reply to message #465986] Thu, 29 December 2005 01:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xiuli_xu.126.com

Can you give me some example code of issueing a layout(...) message? I
have no idea about that.
Re: how to refresh the view [message #466023 is a reply to message #466019] Thu, 29 December 2005 04:11 Go to previous messageGo to next message
venkataramana m is currently offline venkataramana mFriend
Messages: 86
Registered: July 2009
Member
In whichever composite you are adding a control dynamically, that composite needs to be laid out once more as follows ... (this is just an intuitive guess..may work)

/* somewhere after adding a new control */
Composite newControlParent = ...
newControlParent.layout(); /* relayout */


Thanks
~Venkat
Re: how to refresh the view [message #466025 is a reply to message #466023] Thu, 29 December 2005 05:50 Go to previous messageGo to next message
Eclipse UserFriend
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);
Re: how to refresh the view [message #466047 is a reply to message #466025] Thu, 29 December 2005 19:48 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
I *strongly* suggest that you don't use any methods in the OS class because it only exposes platform specific funcitonality. Try:

parent.layout();
jtableParent.validate();
jtable.repaint();


Also, double check that your layout is working fine on the parent of the jtable (Swing parent).
Re: how to refresh the view [message #466057 is a reply to message #466047] Fri, 30 December 2005 02:19 Go to previous message
Eclipse UserFriend
Originally posted by: xiuli_xu.126.com

it does work! thanks. use jtableParent.validate();
Previous Topic:Brwoser - toolbar
Next Topic:Wizard Page Wierdness
Goto Forum:
  


Current Time: Tue Apr 16 16:36:38 GMT 2024

Powered by FUDForum. Page generated in 1.47952 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top