Java Code Examples for info.clearthought.layout.TableLayout#PREFERRED

The following examples show how to use info.clearthought.layout.TableLayout#PREFERRED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAtomLabelDialog.java    From openchemlib-js with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void init() {
   JPanel p1 = new JPanel();
      double[][] size = { {8, TableLayout.PREFERRED, 8, TableLayout.PREFERRED, 8 },
                          {8, TableLayout.PREFERRED, 4, TableLayout.PREFERRED,
                           12, TableLayout.PREFERRED, 4, TableLayout.PREFERRED,
                           12, TableLayout.PREFERRED, 4, TableLayout.PREFERRED,
                           12, TableLayout.PREFERRED, 8} };
      p1.setLayout(new TableLayout(size));

      mTextFieldLabel = new JTextField(1);
      mTextFieldLabel.addActionListener(this);
p1.add(new JLabel("Atom Label:", JLabel.RIGHT), "1,1");
p1.add(mTextFieldLabel, "3,1");
      p1.add(new JLabel("(examples: 'D', 'Li', 'Cys', 'R12', 'R3@C')", JLabel.RIGHT), "1,3,3,3");

      mTextFieldMass = new JTextField(1);
      mTextFieldMass.addActionListener(this);
      p1.add(new JLabel("Atom Mass:", JLabel.RIGHT), "1,5");
      p1.add(mTextFieldMass, "3,5");
      p1.add(new JLabel("(empty for natural abundance)", JLabel.RIGHT), "1,7,3,7");

      mTextFieldValence = new JTextField(1);
      mTextFieldValence.addActionListener(this);
      p1.add(new JLabel("Abnormal Valence:", JLabel.RIGHT), "1,9");
      p1.add(mTextFieldValence, "3,9");
      p1.add(new JLabel("(empty for default valence)", JLabel.RIGHT), "1,11,3,11");

      if (mAtom != -1) {
      	String label = mMol.getAtomLabel(mAtom);
      	String customLabel = mMol.getAtomCustomLabel(mAtom);
          mTextFieldLabel.setText(customLabel == null ? label : customLabel+"@"+label);
          if (mMol.getAtomMass(mAtom) != 0)
              mTextFieldMass.setText(""+mMol.getAtomMass(mAtom));
          if (mMol.getAtomAbnormalValence(mAtom) != -1)
              mTextFieldValence.setText(""+mMol.getAtomAbnormalValence(mAtom));
          }

      mComboBoxRadical = new JComboBox(RADICAL_STATES);
      if (mAtom != -1) {
      	int state = mMol.getAtomRadical(mAtom);
      	mComboBoxRadical.setSelectedIndex(state == Molecule.cAtomRadicalStateD ? 1 :
      									  state == Molecule.cAtomRadicalStateT ? 2 :
      									  state == Molecule.cAtomRadicalStateS ? 3 : 0);
      	}
      p1.add(new JLabel("Radical State:", JLabel.RIGHT), "1,13");
      p1.add(mComboBoxRadical, "3,13");

      JPanel p2 = new JPanel();
      p2.setBorder(BorderFactory.createEmptyBorder(12, 8, 8, 8));
      p2.setLayout(new BorderLayout());
      JPanel ibp = new JPanel();
      ibp.setLayout(new GridLayout(1, 2, 8, 0));
      JButton bcancel = new JButton("Cancel");
      bcancel.addActionListener(this);
      ibp.add(bcancel);
      JButton bok = new JButton("OK");
      bok.addActionListener(this);
      ibp.add(bok);
      p2.add(ibp, BorderLayout.EAST);

getContentPane().add(p1, BorderLayout.CENTER);
getContentPane().add(p2, BorderLayout.SOUTH);
getRootPane().setDefaultButton(bok);

pack();
setLocationRelativeTo(mOwner);
      setVisible(true);
}
 
Example 2
Source File: JBondQueryFeatureDialog.java    From openchemlib-js with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void init(Component parent, ExtendedMolecule mol, int bond) {
mMol = mol;
mBond = bond;

JPanel p1 = new JPanel();
      double[][] size = { {8, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, 8},
                          {8, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
						TableLayout.PREFERRED, TableLayout.PREFERRED, 8,
						TableLayout.PREFERRED, 8, TableLayout.PREFERRED, 8, TableLayout.PREFERRED, 16,
						TableLayout.PREFERRED, 4, TableLayout.PREFERRED, 4, TableLayout.PREFERRED, 16} };
      p1.setLayout(new TableLayout(size));

mCBSingle = new JCheckBox("Single");
p1.add(mCBSingle,"1,1,3,1");

mCBDouble = new JCheckBox("Double");
p1.add(mCBDouble,"1,2,3,2");

mCBTriple = new JCheckBox("Triple");
p1.add(mCBTriple,"1,3,3,3");

mCBDelocalized = new JCheckBox("Delocalized");
p1.add(mCBDelocalized,"1,4,3,4");

mCBMetalLigand = new JCheckBox("Coordinate (0-order)");
p1.add(mCBMetalLigand,"1,5,3,5");

mComboBoxRing = new JComboBox();
mComboBoxRing.addItem("any ring state");
mComboBoxRing.addItem("is not in a ring");
mComboBoxRing.addItem("is any ring bond");
mComboBoxRing.addItem("is non-aromatic ring bond");
mComboBoxRing.addItem("is aromatic bond");
mComboBoxRing.addActionListener(this);
p1.add(mComboBoxRing,"1,7,3,7");

mComboBoxRingSize = new JComboBox();
mComboBoxRingSize.addItem("any ring size");
mComboBoxRingSize.addItem("is in 3-membered ring");
mComboBoxRingSize.addItem("is in 4-membered ring");
mComboBoxRingSize.addItem("is in 5-membered ring");
mComboBoxRingSize.addItem("is in 6-membered ring");
mComboBoxRingSize.addItem("is in 7-membered ring");
p1.add(mComboBoxRingSize, "1,9,3,9");

mCBMatchStereo = new JCheckBox("Match Stereo Configuration", (mol.getBondQueryFeatures(bond) & Molecule.cBondQFMatchStereo) != 0);
mCBMatchStereo.addActionListener(this);
p1.add(mCBMatchStereo, "1,11,3,11");

mCBIsBridge = new JCheckBox("Is atom bridge between");
      mCBIsBridge.addActionListener(this);
      p1.add(mCBIsBridge,"1,13,3,13");

      mComboBoxMinAtoms = new JComboBox();
      int itemCount = (1 << Molecule.cBondQFBridgeMinBits);
      for (int i=0; i<itemCount; i++)
          mComboBoxMinAtoms.addItem(""+i);
      p1.add(mComboBoxMinAtoms,"2,15");
      p1.add(new JLabel(" and"),"3,15");
      mComboBoxMinAtoms.addActionListener(this);

      mComboBoxMaxAtoms = new JComboBox();
      populateComboBoxMaxAtoms(0);
      p1.add(mComboBoxMaxAtoms,"2,17");
      p1.add(new JLabel(" atoms"),"3,17");

JPanel bp = new JPanel();
      bp.setBorder(BorderFactory.createEmptyBorder(12, 8, 8, 8));
      bp.setLayout(new BorderLayout());
      JPanel ibp = new JPanel();
      ibp.setLayout(new GridLayout(1, 6, 8, 0));
      JButton bcancel = new JButton("Cancel");
      bcancel.addActionListener(this);
      ibp.add(bcancel);
      JButton bok = new JButton("OK");
      bok.addActionListener(this);
      ibp.add(bok);
      bp.add(ibp, BorderLayout.EAST);

getContentPane().add(p1,BorderLayout.CENTER);
getContentPane().add(bp,BorderLayout.SOUTH);
getRootPane().setDefaultButton(bok);

      mMol.ensureHelperArrays(Molecule.cHelperRings);
      setInitialStates();

      pack();
      setLocationRelativeTo(parent);
      setVisible(true);
}
 
Example 3
Source File: JTextDrawingObjectDialog.java    From openchemlib-js with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void init(Component owner) {
      mComboBoxTextSize = new JComboBox(TEXT_SIZE_LIST);
mComboBoxTextSize.setEditable(true);
mComboBoxTextSize.setSelectedItem(""+(int)mTextObject.getSize());

      mComboBoxStyle = new JComboBox(TEXT_STYLE_LIST);
int styleIndex = 0;
for (int i=0; i<TEXT_STYLE.length; i++) {
	if (mTextObject.getStyle() == TEXT_STYLE[i]) {
		styleIndex = i;
		break;
		}
	}
mComboBoxStyle.setSelectedIndex(styleIndex);

JComponent menuPanel = new JPanel();
double[][] size = { { 8, TableLayout.PREFERRED, 4, TableLayout.PREFERRED, 8 },
					{ 8, TableLayout.PREFERRED, 4, TableLayout.PREFERRED, 8 } };
menuPanel.setLayout(new TableLayout(size));

menuPanel.add(new JLabel("Text size:"), "1,1");
menuPanel.add(mComboBoxTextSize, "3,1");
menuPanel.add(new JLabel("Text style:"), "1,3");
menuPanel.add(mComboBoxStyle, "3,3");

mTextArea = new JTextArea(mTextObject.getText(), 3, 20);
      mTextArea.setBorder(BorderFactory.createEtchedBorder());
JPanel textPanel = new JPanel();
      textPanel.setBorder(BorderFactory.createEmptyBorder(0,4,0,4));
textPanel.add(mTextArea);

JButton buttonOK = new JButton("OK");
buttonOK.addActionListener(this);
JButton buttonCancel = new JButton("Cancel");
buttonCancel.addActionListener(this);
JPanel innerButtonPanel = new JPanel();
      innerButtonPanel.setLayout(new GridLayout(1,2,8,0));
      innerButtonPanel.add(buttonCancel);
      innerButtonPanel.add(buttonOK);
      innerButtonPanel.setBorder(BorderFactory.createEmptyBorder(8,8,8,8));
JPanel buttonPanel = new JPanel();
      buttonPanel.setLayout(new BorderLayout());
      buttonPanel.add(innerButtonPanel, BorderLayout.EAST);

getContentPane().setLayout(new BorderLayout());
getContentPane().add(menuPanel,  BorderLayout.NORTH);
getContentPane().add(textPanel,  BorderLayout.CENTER);
getContentPane().add(buttonPanel,  BorderLayout.SOUTH);

getRootPane().setDefaultButton(buttonOK);

pack();
setLocationRelativeTo(owner);

mTextArea.requestFocus();
setVisible(true);
}