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 - initial API and implementation
  */
 package de.ipk_gatersleben.bit.bi.edal.rmi.client.gui.editor;
 
 import java.util.Set;
 
 
The ChecksumDialog can be used to edit CheckSum, which implements the MetadataeditDialog class, we can use it with a couple of lines of code:

 ChecksumDialog checksumDialog = new ChecksumDialog(checksum);
 checksumDialog.showOpenDialog();
 

Author(s):
Jinbo Chen
Version:
1.0
 
 public class ChecksumDialog extends MetaDataEditDialog {
 	private static final long serialVersionUID = 1L;
 	private CheckSum checksum;
 
 	private JLabel algorithmlabel;
 	private JLabel chesksumlabel;
 	private JTable table;
 	private DefaultTableModel dm;

Constructs a ChecksumDialog that is initialized with checksum.

Parameters:
checksum CheckSum Object
 
 	public ChecksumDialog(CheckSum checksum) {
 		super();
 		this. = checksum;
 		setTitle("CheckSum Information");
 
 		initUi();
 	}

Returns the CheckSum inputted by user.

Returns:
the CheckSum inputted by user.
 
 	public CheckSum getCheckSum() {
 		CheckSum checkSum = new CheckSum();
 		Vector vector = .getDataVector();
 		if (vector != null) {
 			for (int i = 0; i < vector.size(); i++) {
 				Vector<Stringv = (Vector<String>) vector.get(i);
 				checkSum.add(new CheckSumType(v.get(0), v.get(1)));
 			}
 		}
 
 		return checkSum;
 	}
 
 	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("Algorithm");
		dummyHeader.addElement("CheckSum");
		 = 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);
		/*
		 * algorithmlabel = new JLabel("Algorithm:", JLabel.LEFT); c.fill =
		 * GridBagConstraints.BOTH; c.gridx=0; c.gridy=3; c.gridheight=1;
		 * c.gridwidth=1; c.weightx=0.5;
		 * 
		 * gridbag.setConstraints(algorithmlabel, c);
		 * editPane.add(algorithmlabel);
		 * 
		 * algorithmtext = new JTextField(); c.fill = GridBagConstraints.BOTH;
		 * c.gridx=1; c.gridy=3; c.gridheight=1; c.gridwidth=3; c.weightx=0.5;
		 * 
		 * gridbag.setConstraints(algorithmtext, c);
		 * editPane.add(algorithmtext);
		 * 
		 * chesksumlabel = new JLabel("CheckSum:", JLabel.LEFT); c.fill =
		 * GridBagConstraints.BOTH; c.gridx=0; c.gridy=4; c.gridheight=1;
		 * c.gridwidth=1; c.weightx=0.5;
		 * 
		 * gridbag.setConstraints(chesksumlabel, c);
		 * editPane.add(chesksumlabel);
		 * 
		 * chesksumvaluetext = new JTextField(); c.fill =
		 * GridBagConstraints.BOTH; c.gridx=1; c.gridy=4; c.gridheight=1;
		 * c.gridwidth=3; c.weightx=0.5;
		 * 
		 * gridbag.setConstraints(chesksumvaluetext, c);
		 * editPane.add(chesksumvaluetext);
		 * 
		 * JButton addbtn = new JButton(addAction); c.fill =
		 * GridBagConstraints.BOTH; c.gridx=0; c.gridy=5; c.gridheight=1;
		 * c.gridwidth=1; c.weightx=0.25;
		 * 
		 * gridbag.setConstraints(addbtn, c); editPane.add(addbtn);
		 * 
		 * JButton delbtn= new JButton(delAction); c.fill =
		 * GridBagConstraints.BOTH; c.gridx=2; c.gridy=5; c.gridheight=1;
		 * c.gridwidth=1; c.weightx=0.25;
		 * 
		 * gridbag.setConstraints(delbtn, c); editPane.add(delbtn);
		 */
		contents.add(editPane.);
		this.setSize(new Dimension(320, (int) (320 * 0.618)));
	}
		Vector vector = new Vector();
		if (set != null) {
			for (CheckSumType checkSumType : set) {
				Vector<Stringv = new Vector<String>();
				v.addElement(checkSumType.getAlgorithm());
				v.addElement(checkSumType.getCheckSum());
				vector.addElement(v);
			}
		}
		return vector;
	}
	private Action addAction = new AbstractAction("add") {
		private static final long serialVersionUID = 1L;
		public void actionPerformed(ActionEvent e) {
				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