Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  Copyright (c) 2011 Leibniz Institute of Plant Genetics and Crop Plant Research (IPK), Gatersleben, Germany.
   *  All rights reserved. This program and the accompanying materials
   *  are made available under the terms of the GNU Lesser Public License v2.1
   *  which accompanies this distribution, and is available at
   *  http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
   *
   *  Contributors:
   *      Leibniz Institute of Plant Genetics and Crop Plant Research (IPK), Gatersleben, Germany - RMI Client, FileChooser and WebDAV
  */
 package de.ipk_gatersleben.bit.bi.edal.rmi.client.gui.editor;
 
 import java.util.Set;
 
 
The SubjectsDialog can be used to edit Subjects, which implements the MetadataeditDialog class, we can use it with a couple of lines of code:

 SubjectsDialog subjectsDialog = new SubjectsDialog(subjects, title);
 subjectsDialog.showOpenDialog();
 

Author(s):
Jinbo Chen
Version:
1.0
 
 public class SubjectsDialog extends MetaDataEditDialog {
 
 	private static final long serialVersionUID = 1L;
 	private Set<UntypedDatasubjects;
 
 	private JTable table;
 	private DefaultTableModel dm;

Constructs a SubjectsDialog that is initialized with subjects.

Parameters:
subjects UntypedData Set
 
 	public SubjectsDialog(Set<UntypedDatasubjectsString title) {
 		super();
 		this. = subjects;
 		setTitle(title);
 
 		initUi();
 	}

Returns the Subjects typed in by user.

Returns:
the Subjects typed in by user.
 
 	public Set<UntypedDatagetSubjects() {
 		Set<UntypedDataidlist = new HashSet<UntypedData>();
 
 		int row = .getRowCount();
 		for (int i = 0; i < rowi++) {
 			idlist.add(new UntypedData(.getValueAt(i, 0).toString()));
 		}
 
 		return idlist;
 	}
 
 	public void initdata() {
 
 	}
 
 	private void initUi() {
 		JPanel contents = (JPanelgetContentPane();
 		contents.setLayout(new BorderLayout());
		JPanel editPane = new JPanel();
		GridBagLayout gridbag = new GridBagLayout();
		editPane.setLayout(gridbag);
		c.gridx = 0;
		c.gridy = 0;
		c.gridheight = 3;
		c.gridwidth = 4;
		c.weightx = 1.0;
		Vector dummyHeader = new Vector();
		dummyHeader.addElement("");
		 = new JTable();
		JScrollPane scrollTable = new JScrollPane();
		scrollTable.setColumnHeader(null);
		scrollTable.setMinimumSize(new Dimension(320, 80));
		Box tableBox = new Box(.);
		tableBox.add(scrollTable);
		gridbag.setConstraints(tableBoxc);
		editPane.add(tableBox);
		c.gridx = 0;
		c.gridy = 3;
		c.gridheight = 1;
		c.gridwidth = 2;
		c.weightx = 0.5;
		editPane.add();
		JButton addbtn = new JButton();
		c.gridx = 2;
		c.gridy = 3;
		c.gridheight = 1;
		c.gridwidth = 1;
		c.weightx = 0.25;
		gridbag.setConstraints(addbtnc);
		editPane.add(addbtn);
		JButton delbtn = new JButton();
		c.gridx = 3;
		c.gridy = 3;
		c.gridheight = 1;
		c.gridwidth = 1;
		c.weightx = 0.25;
		gridbag.setConstraints(delbtnc);
		editPane.add(delbtn);
		contents.add(editPane.);
		this.setSize(new Dimension(320, (int) (320 * 0.618)));
	}
		Vector vector = new Vector();
		if (strs != null) {
			for (UntypedData idenstr : strs) {
				Vector<Stringv = new Vector<String>();
				v.addElement(idenstr.getString());
				vector.addElement(v);
			}
		}
		return vector;
	}
	private Action addAction = new AbstractAction("add") {
		private static final long serialVersionUID = 1L;
		public void actionPerformed(ActionEvent e) {
			if (.getText().trim().length() > 0) {
				Vector<Stringv = new Vector<String>();
			}
		}
	};
	private Action delAction = new AbstractAction("remove") {
		private static final long serialVersionUID = 1L;
		public void actionPerformed(ActionEvent e) {
			if (.getSelectedRow() > -1) {
			}
		}
	};
New to GrepCode? Check out our FAQ X