Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Using a Table in WindowBuilder(Trouble with Tables)
Using a Table in WindowBuilder [message #1404526] Sun, 03 August 2014 02:17 Go to next message
Joey Nunez is currently offline Joey NunezFriend
Messages: 1
Registered: August 2014
Junior Member
I'm having trouble figuring out how to use the tables as part of my GUI in WindowBuilder. I Have my code set up to prompt the user for their name and ID number, and I would like this to be inserted into a table below. The problem is, I cant figure out how to do this anywhere. Can anyone help?

import java.awt.event.ActionEvent;


public class Frame {

	protected Shell shell;
	private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
	private Table table;
	private Table table_1;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Frame window = new Frame();
			window.open();
			
	
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(460, 343);
		shell.setText("4296 Log-In Application");
		shell.setLayout(null);
		
		Button btnNewButton = new Button(shell, SWT.NONE);
		btnNewButton.setBounds(21, 10, 188, 25);
		btnNewButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) 
			{
				
				String x = JOptionPane.showInputDialog(null, "Full Name");
				if(x == null || x.equals(""))
				{
					JOptionPane.showMessageDialog(null, "Log-In Void");
				}
				
				else
				{
					String y = JOptionPane.showInputDialog(null, "ID Number");
					if(y == null || y.equals(""))
					{
						JOptionPane.showMessageDialog(null, "Log-In Void");
					}
					else
					{
						JOptionPane.showMessageDialog(null, "User " + x + " With ID Number " + y + " Has Logged In... Congrats");

					}
				}
			}

		});
		btnNewButton.setText("Log-In");
		
		Button btnNewButton_1 = new Button(shell, SWT.NONE);
		btnNewButton_1.setBounds(237, 10, 188, 25);
		btnNewButton_1.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) 
			{
				
				String y = JOptionPane.showInputDialog(null, "ID Number");
				
			 	if(y == null || y.equals(""))
			 	{
				JOptionPane.showMessageDialog(null, "Log-Out Void");
			 	}
				else
				{
					JOptionPane.showMessageDialog(null, "User with ID Number " + y + " Has Been Logged Out");

				}

				
				
			}
		});
		btnNewButton_1.setText("Log-Out");

		
		ProgressBar progressBar = new ProgressBar(shell, SWT.NONE);
		progressBar.setBounds(21, 41, 404, 17);
		
		Menu menu = new Menu(shell, SWT.BAR);
		shell.setMenuBar(menu);
		
		MenuItem mntmNewSubmenu = new MenuItem(menu, SWT.CASCADE);
		mntmNewSubmenu.setText("Table");
		
		Menu menu_1 = new Menu(mntmNewSubmenu);
		mntmNewSubmenu.setMenu(menu_1);
		
		MenuItem mntmTableReset = new MenuItem(menu_1, SWT.NONE);
		mntmTableReset.setText("Table Reset");
		
		table_1 = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION);
		table_1.setBounds(21, 64, 404, 210);
		formToolkit.adapt(table_1);
		formToolkit.paintBordersFor(table_1);
		table_1.setHeaderVisible(true);
		table_1.setLinesVisible(true);
		
		TableColumn tblclmnUser = new TableColumn(table_1, SWT.NONE);
		tblclmnUser.setResizable(false);
		tblclmnUser.setMoveable(true);
		tblclmnUser.setWidth(100);
		tblclmnUser.setText("Name");
		
		
		TableColumn tblclmnIdNumber = new TableColumn(table_1, SWT.NONE);
		tblclmnIdNumber.setWidth(100);
		tblclmnIdNumber.setResizable(false);
		tblclmnIdNumber.setMoveable(true);
		tblclmnIdNumber.setText("ID Number");
		
		
		TableColumn tblclmnLoginTime = new TableColumn(table_1, SWT.NONE);
		tblclmnLoginTime.setWidth(100);
		tblclmnLoginTime.setResizable(false);
		tblclmnLoginTime.setMoveable(true);
		tblclmnLoginTime.setText("Log-In Time");
		
		TableColumn tblclmnLogoutTime = new TableColumn(table_1, SWT.NONE);
		tblclmnLogoutTime.setWidth(100);
		tblclmnLogoutTime.setResizable(false);
		tblclmnLogoutTime.setMoveable(true);
		tblclmnLogoutTime.setText("LogOut Time");
		
		
		


	}
}

Re: Using a Table in WindowBuilder [message #1406311 is a reply to message #1404526] Sat, 09 August 2014 17:46 Go to previous message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
THis sounds like a how-do-I-use-SWT question better suited to the SWT forum.

This forum is for questions about WindowBuilder itself.
Previous Topic:Odd WindowBuilder SWT rendering
Next Topic:WindowBuilder with maven
Goto Forum:
  


Current Time: Tue Apr 16 10:51:25 GMT 2024

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

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

Back to the top