Home » Eclipse Projects » Standard Widget Toolkit (SWT) » refreshing bottom pane
| |
Re: refreshing bottom pane [message #455096 is a reply to message #455090] |
Fri, 06 May 2005 09:26 |
Amit Kumar Messages: 2 Registered: July 2009 |
Junior Member |
|
|
Hi
I herewith send the code. The main window contains 2 panes. Top pane
contains a Text field and a Search Button. The bottom pane has a Table. If
we press Search button, based on the value entered some static data to be
displayed in the Table in the bottom pane. If we enter as 'Ami', some
static data as 'Ami1,Ami2,Ami3'... to be displayed in the Table. Next time
if we give as 'Sai', the table data is to be 'Sai1,sai2,Sai3...'. The
table is to be refreshed when we press the search button everytime.
Here is the code:
/*
* Created on May 3, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author Amit
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.ShellListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Sash;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
class TopForm1 {
SearchVO searchVO = new SearchVO();
Label lblName;
Label lblComment;
Label lblUpdated;
Label lblType;
Label lblModule;
Label lblLanguage;
Text txtName;
Text txtComment;
Combo cmbUpdated;
Combo cmbType;
Combo cmbModule;
Combo cmbLanguage;
Button btnSearch;
Button btnReset;
TopForm1(final Shell shell){
FormData formData;
Font font=new Font(null, "Arial", 10, SWT.NORMAL);
Color silver=new Color(null,192,192,192);
Color pink=new Color(null,255,245,238);
RowData data =new RowData();
Composite composite = new Composite(shell,SWT.NULL);
data =new RowData();
data.height=100;
data.width=800;
composite.setLayoutData(data);
composite.setBackground(pink);
composite.setLayout(new FormLayout());
lblName = new Label(composite, SWT.LEFT);
lblName.setText("Name:");
lblName.setFont(font);
lblName.setBackground(pink);
formData = new FormData();
formData.right = new FormAttachment(6,-2);
formData.bottom = new FormAttachment(20,0);
lblName.setLayoutData(formData);
txtName = new Text(composite, SWT.SINGLE|SWT.BORDER);
txtName.setBackground(silver);
formData = new FormData();
formData.right = new FormAttachment(lblName,248);
formData.bottom = new FormAttachment(lblName,20);
formData.width=150;
txtName.setLayoutData(formData);
btnSearch=new Button(composite, SWT.PUSH|SWT.BORDER);
btnSearch.setText("Search");
btnSearch.addSelectionListener(new SelectionListener()
{
public void widgetSelected(SelectionEvent event)
{
System.out.println(txtName.getText());
BottomList bottomList=new BottomList(1);
bottomList.drawBottomList(shell);
}
public void widgetDefaultSelected(SelectionEvent event)
{
}
});
formData = new FormData();
formData.right = new FormAttachment(20,10);
formData.bottom = new FormAttachment(90,0);
formData.width=75;
formData.height=20;
btnSearch.setLayoutData(formData);
btnReset=new Button(composite, SWT.PUSH|SWT.BORDER);
btnReset.setText("Reset");
btnReset.addSelectionListener(new SelectionListener()
{
public void widgetSelected(SelectionEvent event)
{
txtName.setText("");
}
public void widgetDefaultSelected(SelectionEvent event)
{
//txtName.setText("No worries!");
}
});
formData = new FormData();
formData.right = new FormAttachment(30,10);
formData.bottom = new FormAttachment(90,0);
formData.width=75;
formData.height=20;
btnReset.setLayoutData(formData);
silver.dispose();
pink.dispose();
font.dispose();
}
}
class BottomList1 {
BottomList1(){
}
public void drawBottomList(Shell shell){
TabFolder tabFldrResult;
TabItem tabItmResult;
Table tblResult;
Sash sash=new Sash(shell,SWT.HORIZONTAL);
Composite composite = new Composite(shell,SWT.NULL);
RowData data;
data =new RowData();
data.height=400;
data.width=800;
composite.setLayoutData(data);
composite.setBounds(100, 150, 800, 450);
composite.setLayout(new FillLayout());
tabFldrResult=new TabFolder(composite, SWT.BORDER);
tabFldrResult.setLayout(new FillLayout());
tabItmResult=new TabItem(tabFldrResult,SWT.NULL);
tabItmResult.setText("Results");
tblResult = new Table(tabFldrResult,SWT.BORDER);
tabFldrResult.setLayout(new FillLayout());
tblResult.setLayout(new FillLayout());
tblResult.setHeaderVisible(true);
tblResult.setLinesVisible(true);
TableColumn tbclmData1 = new TableColumn(tblResult, SWT.NULL);
tbclmData1.setText("Name");
tbclmData1.setWidth(200);
}
}
public class SearchWindow1{
TopForm1 topForm;
BottomList1 bottomList;
Display display;
Shell shell;
Composite parentComposite;
ShellListener sel;
public void drawSearchWindow()
{
try{
searchVO=new SearchVO();
display=new Display();
shell= new Shell(display);
shell.setBounds(100, 100, 810, 600);
shell.setLayout(new RowLayout());
topForm=new TopForm1(shell);
bottomList=new BottomList1();
bottomList.drawBottomList(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}catch(Exception ex)
{
ex.printStackTrace();
}
}
public static void main(String args[]){
SearchWindow searchWindow=new SearchWindow();
searchWindow.drawSearchWindow();
}
}
Need your help
Thanks in advance
Amit Kumar
|
|
|
Goto Forum:
Current Time: Thu Apr 18 18:20:27 GMT 2024
Powered by FUDForum. Page generated in 0.02644 seconds
|