javax.swing.JTextField#setMaximumSize ( )源码实例Demo

下面列出了javax.swing.JTextField#setMaximumSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: biojava   文件: SelectMultiplePanel.java
private Box getDomainPanel(JTextField f){

		JLabel l01 = new JLabel("Input structures:");

		Box hBox = Box.createHorizontalBox();
		hBox.add(Box.createGlue());
		hBox.add(l01);

		f.setMaximumSize(new Dimension(Short.MAX_VALUE,30));
		f.setToolTipText("Provide structure identifiers space separated.");

		hBox.add(Box.createVerticalGlue());
		hBox.add(f, BorderLayout.CENTER);
		hBox.add(Box.createGlue());

		return hBox;
	}
 
private void initComponents() {
   	setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));

   	JPanel panel = new JPanel();
   	panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
   	panel.add(new JLabel("File"));
   	panel.add(Box.createHorizontalStrut(6));
   	fileTextField = new JTextField(20);
   	fileTextField.setMaximumSize(fileTextField.getPreferredSize());
   	panel.add(fileTextField);
   	panel.add(Box.createHorizontalStrut(6));
   	JButton browseButton = new JButton("...");
   	browseButton.addActionListener(new ActionListener() {

		public void actionPerformed(ActionEvent event) {
			browse();
		}

   	});
   	panel.add(browseButton);
   	add(panel);
}
 
源代码3 项目: PacketProxy   文件: GUIOptionPrivateDNS.java
private JTextField createAddressField(){
	JTextField text = new JTextField("");
	try {
		text.setText(getLocalIP());
	} catch (Exception e) {
		e.printStackTrace();
	}
	text.setMaximumSize(new Dimension(300, 30));
	text.setEnabled(false);
	return text;
}
 
源代码4 项目: netbeans   文件: TemplatesPanelGUI.java
private void adjustQuickSearch( QuickSearch qs ) {
    qs.setAlwaysShown( true );
    Component qsComponent = panelFilter.getComponent( 0 );
    if( qsComponent instanceof JComponent ) {
        ((JComponent)qsComponent).setBorder( BorderFactory.createEmptyBorder() );
    }
    JTextField textField = getQuickSearchField();
    if( null != textField )
        textField.setMaximumSize( null );
}
 
源代码5 项目: gcs   文件: SheetPreferences.java
private JTextField createTextField(String tooltip, String value) {
    JTextField field = new JTextField(value);
    field.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
    field.getDocument().addDocumentListener(this);
    Dimension size    = field.getPreferredSize();
    Dimension maxSize = field.getMaximumSize();
    maxSize.height = size.height;
    field.setMaximumSize(maxSize);
    add(field);
    return field;
}
 
源代码6 项目: gcs   文件: OutputPreferences.java
private JTextField createTextField(String tooltip, String value) {
    JTextField field = new JTextField(value);
    field.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
    field.getDocument().addDocumentListener(this);
    Dimension size    = field.getPreferredSize();
    Dimension maxSize = field.getMaximumSize();
    maxSize.height = size.height;
    field.setMaximumSize(maxSize);
    add(field);
    return field;
}
 
源代码7 项目: gcs   文件: DisplayPreferences.java
private JTextField createTextField(String tooltip, String value) {
    JTextField field = new JTextField(value);
    field.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
    field.getDocument().addDocumentListener(this);
    Dimension size    = field.getPreferredSize();
    Dimension maxSize = field.getMaximumSize();
    maxSize.height = size.height;
    field.setMaximumSize(maxSize);
    add(field);
    return field;
}
 
源代码8 项目: jaamsim   文件: GUIFrame.java
private void addSnapToGridField(JToolBar buttonBar, Insets margin) {

		gridSpacing = new JTextField("1000000 m") {
			@Override
			protected void processFocusEvent(FocusEvent fe) {
				if (fe.getID() == FocusEvent.FOCUS_LOST) {
					GUIFrame.this.setSnapGridSpacing(this.getText().trim());
				}
				else if (fe.getID() == FocusEvent.FOCUS_GAINED) {
					gridSpacing.selectAll();
				}
				super.processFocusEvent( fe );
			}
		};

		gridSpacing.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent evt) {
				GUIFrame.this.setSnapGridSpacing(gridSpacing.getText().trim());
				controlStartResume.requestFocusInWindow();
			}
		});

		gridSpacing.setMaximumSize(gridSpacing.getPreferredSize());
		int hght = snapToGrid.getPreferredSize().height;
		gridSpacing.setPreferredSize(new Dimension(gridSpacing.getPreferredSize().width, hght));

		gridSpacing.setHorizontalAlignment(JTextField.RIGHT);
		gridSpacing.setToolTipText(formatToolTip("Snap Grid Spacing",
				"Distance between adjacent grid points, e.g. 0.1 m, 10 km, etc."));

		gridSpacing.setEnabled(snapToGrid.isSelected());

		buttonBar.add(gridSpacing);
	}
 
源代码9 项目: jaamsim   文件: GUIFrame.java
private void addTextHeightField(JToolBar buttonBar, Insets margin) {

		textHeight = new JTextField("1000000 m") {
			@Override
			protected void processFocusEvent(FocusEvent fe) {
				if (fe.getID() == FocusEvent.FOCUS_LOST) {
					GUIFrame.this.setTextHeight(this.getText().trim());
				}
				super.processFocusEvent( fe );
			}
		};

		textHeight.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent evt) {
				GUIFrame.this.setTextHeight(textHeight.getText().trim());
				controlStartResume.requestFocusInWindow();
			}
		});

		textHeight.setMaximumSize(textHeight.getPreferredSize());
		textHeight.setPreferredSize(new Dimension(textHeight.getPreferredSize().width,
				fileSave.getPreferredSize().height));

		textHeight.setHorizontalAlignment(JTextField.RIGHT);
		textHeight.setToolTipText(formatToolTip("Text Height",
				"Sets the height of the text, e.g. 0.1 m, 200 cm, etc."));

		buttonBar.add(textHeight);
	}
 
源代码10 项目: opensim-gui   文件: MeasurementSetPanel.java
public JComponent getMarkerComponent(final String name, final int measurementIndex, final int markerPairIndex, final int index) {
   Dimension dim = new Dimension(MARKER_NAME_WIDTH,HEIGHT);
   JTextField markerButton = new JTextField(name);
   markerButton.setEditable(false);
   markerButton.setHorizontalAlignment(SwingConstants.CENTER);
   // Indicate marker does not exist in model's marker set with red color (though the measurement may still be invalid
   // if this marker is not found in the marker data passed to the model scaler)
   boolean markerInModel = measurementSetModel.getMarkerExistsInModel(name);
   boolean markerInMeasurementTrial = measurementSetModel.getMarkerExistsInMeasurementTrial(name);
   if(!markerInModel || !markerInMeasurementTrial) {
      markerButton.setBackground(invalidColor);
      if(!markerInModel && !markerInMeasurementTrial) markerButton.setToolTipText("Marker not in model or measurement marker data!");
      else if(!markerInModel) markerButton.setToolTipText("Marker not in model!");
      else markerButton.setToolTipText("Marker not in measurement marker data!");
   } else {
      markerButton.setBackground(Color.white);
      markerButton.setToolTipText(null);
   }
   markerButton.setMinimumSize(dim);
   markerButton.setMaximumSize(dim);
   markerButton.setPreferredSize(dim);
   markerButton.setBorder(markerInnerBorder);
   markerButton.addMouseListener(new MouseAdapter() {
      public void mousePressed(MouseEvent evt) {
         JPopupMenu popup = new JPopupMenu();
         for(int i=0; i<markerNames.size(); i++) {
            JRadioButtonMenuItem item = new JRadioButtonMenuItem(new ChangeMarkerPairMarkerAction(markerNames.get(i), measurementIndex, markerPairIndex, index));
            if(markerNames.get(i).equals(name)) item.setSelected(true);
            popup.add(item);
         }
         popup.setLayout(new GridLayout(25,markerNames.size()/25+1));
         popup.show(evt.getComponent(),evt.getX(),evt.getY());
      }
   });

   return markerButton;
}
 
源代码11 项目: niftyeditor   文件: FileChooserEditor.java
private JPanel createAccessor(){
    JPanel result = new JPanel();
    BoxLayout layout = new BoxLayout(result, BoxLayout.Y_AXIS);
    result.setLayout(layout);
    absolute = new JRadioButton("Absolute path");
    relative = new JRadioButton("Relative to Assets folder");
    copy = new JRadioButton("Copy file in Assets folder");
    copy.addActionListener(this);
    JTextField absText = new JTextField();
    absText.setEditable(false);
    JTextField relText = new JTextField();
    relText.setEditable(false);
    copyText = new JTextField();
    copyText.setMaximumSize(new Dimension(400, 25));
    copyText.setEnabled(false);
    group = new ButtonGroup();
    group.add(copy);
    group.add(relative);
    group.add(absolute);
    absolute.setSelected(true);
    result.add(new ImagePreview(jFileChooser1));
    result.add(absolute);
    result.add(relative);
    result.add(copy);
    result.add(copyText);
    result.add(new JPanel());
    return result;
}
 
源代码12 项目: gpx-animator   文件: ColorSelector.java
/**
 * Create the panel.
 */
public ColorSelector() {
    final ResourceBundle resourceBundle = Preferences.getResourceBundle();

    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));

    colorTextField = new JTextField();
    colorTextField.setEditable(false);
    colorTextField.setMaximumSize(new Dimension(2147483647, 21));
    colorTextField.setPreferredSize(new Dimension(55, 21));
    add(colorTextField);
    colorTextField.setColumns(10);

    final Component rigidArea = Box.createRigidArea(new Dimension(5, 0));
    add(rigidArea);

    selectButton = new JButton(resourceBundle.getString("ui.dialog.color.button.select"));
    selectButton.addActionListener(e -> {
        final JColorChooser chooserPane = new JColorChooser();
        chooserPane.setColor(colorTextField.getBackground());
        final ActionListener okListener = e1 -> setColor(chooserPane.getColor());
        final JDialog colorChooser = JColorChooser.createDialog(
                ColorSelector.this, resourceBundle.getString("ui.dialog.color.title"), true, chooserPane, okListener, null);
        colorChooser.setVisible(true);
    });

    add(selectButton);
}
 
源代码13 项目: netbeans   文件: DataViewUI.java
private void initToolbarWest(JToolBar toolbar, ActionListener outputListener, boolean nbOutputComponent) {

        if (!nbOutputComponent) {
            JButton[] btns = getEditButtons();
            for (JButton btn : btns) {
                if (btn != null) {
                    toolbar.add(btn);
                }
            }
        }

        toolbar.addSeparator(new Dimension(10, 10));

        //add refresh button
        URL url = getClass().getResource(IMG_PREFIX + "refresh.png"); // NOI18N
        refreshButton = new JButton(new ImageIcon(url));
        refreshButton.setToolTipText(NbBundle.getMessage(DataViewUI.class, "TOOLTIP_refresh"));
        refreshButton.addActionListener(outputListener);
        processButton(refreshButton);

        toolbar.add(refreshButton);

        //add limit row label
        limitRow = new JLabel(NbBundle.getMessage(DataViewUI.class, "LBL_max_rows"));
        limitRow.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 8));
        toolbar.add(limitRow);

        //add refresh text field
        refreshField = new JTextField(5);
        refreshField.setMinimumSize(refreshField.getPreferredSize());
        refreshField.setMaximumSize(refreshField.getPreferredSize());
        refreshField.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                refreshField.selectAll();
            }
        });
        refreshField.addActionListener(outputListener);
        toolbar.add(refreshField);
        toolbar.addSeparator(new Dimension(10, 10));

        JLabel fetchedRowsNameLabel = new JLabel(NbBundle.getMessage(DataViewUI.class, "LBL_fetched_rows"));
        fetchedRowsNameLabel.getAccessibleContext().setAccessibleName(NbBundle.getMessage(DataViewUI.class, "LBL_fetched_rows"));
        fetchedRowsNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
        toolbar.add(fetchedRowsNameLabel);
        fetchedRowsLabel = new JLabel();
        toolbar.add(fetchedRowsLabel);

        toolbar.addSeparator(new Dimension(10, 10));
    }
 
源代码14 项目: gate-core   文件: NewResourceDialog.java
protected void initGuiComponents(){
  this.getContentPane().setLayout(new BoxLayout(this.getContentPane(),
                                                BoxLayout.Y_AXIS));

  //name field
  Box nameBox = Box.createHorizontalBox();
  nameBox.add(Box.createHorizontalStrut(5));
  nameBox.add(new JLabel("Name: "));
  nameBox.add(Box.createHorizontalStrut(5));
  nameField = new JTextField(30);
  nameField.setMaximumSize(
      new Dimension(Integer.MAX_VALUE, nameField.getPreferredSize().height));
  nameField.setRequestFocusEnabled(true);
  nameField.selectAll();
  nameField.setVerifyInputWhenFocusTarget(false);
  nameBox.add(nameField);
  nameField.setToolTipText("Enter a name for the resource");
  
  nameBox.add(Box.createHorizontalStrut(5));
  nameBox.add(Box.createHorizontalGlue());
  this.getContentPane().add(nameBox);
  this.getContentPane().add(Box.createVerticalStrut(5));

  //parameters table
  parametersEditor = new ResourceParametersEditor();
  tableScroll = new JScrollPane(parametersEditor);
  this.getContentPane().add(tableScroll);
  this.getContentPane().add(Box.createVerticalStrut(5));
  this.getContentPane().add(Box.createVerticalGlue());
  //buttons box
  JPanel buttonsBox = new JPanel();
  buttonsBox.setLayout(new BoxLayout(buttonsBox, BoxLayout.X_AXIS));
  buttonsBox.add(Box.createHorizontalStrut(10));
  buttonsBox.add(okBtn = new JButton("OK"));
  buttonsBox.add(Box.createHorizontalStrut(10));
  buttonsBox.add(cancelBtn = new JButton("Cancel"));
  buttonsBox.add(Box.createHorizontalStrut(10));
  buttonsBox.add(helpBtn = new JButton("Help"));
  buttonsBox.add(Box.createHorizontalStrut(10));
  this.getContentPane().add(buttonsBox);
  this.getContentPane().add(Box.createVerticalStrut(5));
  setSize(400, 300);

  getRootPane().setDefaultButton(okBtn);
}
 
源代码15 项目: gate-core   文件: DocumentExportMenu.java
protected void initGuiComponents() {
  this.getContentPane().setLayout(
          new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));

  // name field
  Box nameBox = Box.createHorizontalBox();
  nameBox.add(Box.createHorizontalStrut(5));
  nameBox.add(new JLabel("Save To:"));
  nameBox.add(Box.createHorizontalStrut(5));
  txtFileName = new JTextField(30);
  txtFileName.setMaximumSize(new Dimension(Integer.MAX_VALUE, txtFileName
          .getPreferredSize().height));
  txtFileName.setRequestFocusEnabled(true);
  txtFileName.setVerifyInputWhenFocusTarget(false);
  nameBox.add(txtFileName);
  // nameField.setToolTipText("Enter a name for the resource");

  nameBox.add(Box.createHorizontalStrut(5));
  nameBox.add(fileBtn = new JButton(MainFrame.getIcon("OpenFile")));
  nameBox.add(Box.createHorizontalGlue());
  this.getContentPane().add(nameBox);
  this.getContentPane().add(Box.createVerticalStrut(5));

  // parameters table
  parametersEditor = new ResourceParametersEditor();
  this.getContentPane().add(new JScrollPane(parametersEditor));
  this.getContentPane().add(Box.createVerticalStrut(5));
  this.getContentPane().add(Box.createVerticalGlue());
  // buttons box
  JPanel buttonsBox = new JPanel();
  buttonsBox.setLayout(new BoxLayout(buttonsBox, BoxLayout.X_AXIS));
  buttonsBox.add(Box.createHorizontalStrut(10));
  buttonsBox.add(okBtn = new JButton("OK"));
  buttonsBox.add(Box.createHorizontalStrut(10));
  buttonsBox.add(cancelBtn = new JButton("Cancel"));
  buttonsBox.add(Box.createHorizontalStrut(10));
  this.getContentPane().add(buttonsBox);
  this.getContentPane().add(Box.createVerticalStrut(5));
  setSize(400, 300);

  getRootPane().setDefaultButton(okBtn);
}
 
源代码16 项目: nextreports-designer   文件: LogPanel.java
public LogPanel() {
    if (tailer == null) {

        setPreferredSize(new Dimension(400, 300));
        setLayout(new BorderLayout());

        textArea = new JTextArea();
        textArea.setEditable(false);
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        JScrollPane scrollPanel = new JScrollPane(textArea);

        linesTextField = new JTextField();
        linesTextField.setPreferredSize(dim);
        linesTextField.setMinimumSize(dim);
        linesTextField.setMaximumSize(dim);
        linesTextField.setText(String.valueOf(LINES));

        JToolBar toolBar = new JToolBar();
        toolBar.setRollover(true);
        toolBar.add(new ClearLogAction(textArea));
        toolBar.add(new ReloadLogAction(textArea, this));

        JPanel topPanel = new JPanel();
        topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS));
        topPanel.add(toolBar);
        topPanel.add(Box.createHorizontalStrut(5));
        topPanel.add(new JLabel(I18NSupport.getString("logpanel.last.lines")));
        topPanel.add(Box.createHorizontalStrut(5));
        topPanel.add(linesTextField);
        topPanel.add(Box.createHorizontalGlue());

        add(topPanel, BorderLayout.NORTH);
        add(scrollPanel, BorderLayout.CENTER);

        final File log = new File(LOG);
        if (!log.exists()) {
            try {
                new File(LOG_DIR).mkdirs();
                boolean created = log.createNewFile();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }

        // read existing text in log
        Thread t = new Thread(new Runnable() {
            public void run() {
                Cursor hourGlassCursor = new Cursor(Cursor.WAIT_CURSOR);
                setCursor(hourGlassCursor);

                //@todo
                //reload(log, textArea);

                tailer = new LogFileTailer(log, 1000, false);
                tailer.addLogFileTailerListener(LogPanel.this);
                tailer.setPriority(Thread.MIN_PRIORITY);

                // very consuming !!!
                //tailer.start();

                Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR);
                setCursor(normalCursor);
            }
        }, "NEXT : " + getClass().getSimpleName());
        t.start();

    }
}
 
源代码17 项目: rtg-tools   文件: RocPlot.java
/**
 * Creates a new swing plot.
 * @param precisionRecall true defaults to precision recall graph
 * @param interpolate if true, enable curve interpolation
 */
RocPlot(boolean precisionRecall, boolean interpolate) {
  mInterpolate = interpolate;
  mMainPanel = new JPanel();
  UIManager.put("FileChooser.readOnly", Boolean.TRUE);
  mFileChooser = new JFileChooser();
  final Action details = mFileChooser.getActionMap().get("viewTypeDetails");
  if (details != null) {
    details.actionPerformed(null);
  }
  mFileChooser.setMultiSelectionEnabled(true);
  mFileChooser.setFileFilter(new RocFileFilter());
  mZoomPP = new RocZoomPlotPanel();
  mZoomPP.setOriginIsMin(true);
  mZoomPP.setTextAntialiasing(true);
  mProgressBar = new JProgressBar(-1, -1);
  mProgressBar.setVisible(true);
  mProgressBar.setStringPainted(true);
  mProgressBar.setIndeterminate(true);
  mStatusLabel = new JLabel();
  mPopup = new JPopupMenu();
  mRocLinesPanel = new RocLinesPanel(this);
  mScrollPane = new JScrollPane(mRocLinesPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  mScrollPane.setWheelScrollingEnabled(true);
  mLineWidthSlider = new JSlider(JSlider.HORIZONTAL, LINE_WIDTH_MIN, LINE_WIDTH_MAX, 1);
  mScoreCB = new JCheckBox("Show Scores");
  mScoreCB.setSelected(true);
  mSelectAllCB = new JCheckBox("Select / Deselect all");
  mTitleEntry = new JTextField("ROC");
  mTitleEntry.setMaximumSize(new Dimension(Integer.MAX_VALUE, mTitleEntry.getPreferredSize().height));
  mOpenButton = new JButton("Open...");
  mOpenButton.setToolTipText("Add a new curve from a file");
  mCommandButton = new JButton("Cmd...");
  mCommandButton.setToolTipText("Send the equivalent rocplot command-line to the terminal");
  final ImageIcon icon = createImageIcon("com/rtg/graph/resources/realtimegenomics_logo.png", "RTG Logo");
  mIconLabel = new JLabel(icon);
  mIconLabel.setBackground(new Color(16, 159, 205));
  mIconLabel.setForeground(Color.WHITE);
  mIconLabel.setOpaque(true);
  mIconLabel.setFont(new Font("Arial", Font.BOLD, 24));
  mIconLabel.setHorizontalAlignment(JLabel.LEFT);
  mIconLabel.setIconTextGap(50);
  if (icon != null) {
    mIconLabel.setMinimumSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
  }
  mGraphType = new JComboBox<>(new String[] {ROC_PLOT, PRECISION_SENSITIVITY});
  mGraphType.setSelectedItem(precisionRecall ? PRECISION_SENSITIVITY : ROC_PLOT);
  configureUI();
}
 
源代码18 项目: ontopia   文件: TypesConfigFrame.java
private JPanel createIconPanel() {
  JPanel iconPanel = new JPanel();
  iconPanel.setLayout(new BoxLayout(iconPanel, BoxLayout.X_AXIS));
  iconPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory
      .createEtchedBorder(), Messages.getString("Viz.IconBorderTitle")));
  iconPanel.add(Box.createHorizontalStrut(10));
  iconPanel.add(new JLabel(Messages.getString("Viz.IconFilename")));
  iconPanel.add(Box.createHorizontalStrut(10));

  filenameField = new JTextField(15);
  // Stupid ... stupid ... stupid ... This is the only way I would get the components to layout correctly !
  filenameField.setMaximumSize(new Dimension((int) (filenameField
      .getMaximumSize().getWidth()), (int) (filenameField.getPreferredSize()
      .getHeight())));
  filenameField.setEditable(false);

  iconPanel.add(filenameField);
  iconPanel.add(Box.createHorizontalStrut(10));

  // Must be final to refer to in inner class.
  final Component thisComponent = this;

  JButton fileButton = new JButton(Messages.getString("Viz.IconBrowseButton"));
  fileButton.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent e) {
      try {
        String filename = promptForFile();
        if (filename != null) {
          setSelectedIconFilename(filename);
          setIconFilename(filename);
        }
      } catch (java.security.AccessControlException exception) {
        ErrorDialog.showError(thisComponent, Messages.getString(
            "Viz.FileBrowseFailure"));
      }
    }
  });

  iconPanel.add(fileButton);
  iconPanel.add(Box.createHorizontalStrut(10));

  clearButton = new JButton(Messages.getString("Viz.IconClear"));
  clearButton.setEnabled(false);
  clearButton.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent anE) {
      setSelectedIconFilename(null);
      setIconFilename(null);
    }
  });

  iconPanel.add(clearButton);
  return iconPanel;
}
 
源代码19 项目: libreveris   文件: Options.java
/**
 * Creates a new Options object.
 */
public Options ()
{
    // Preload constant units
    UnitManager.getInstance()
            .preLoadUnits(Main.class.getName());

    frame = new JFrame();
    frame.setName("optionsFrame");
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.getContentPane()
            .setLayout(new BorderLayout());

    JToolBar toolBar = new JToolBar(JToolBar.HORIZONTAL);
    frame.add(toolBar, BorderLayout.NORTH);

    // Dump button
    JButton dumpButton = new JButton(dumping);
    dumpButton.setName("optionsDumpButton");
    toolBar.add(dumpButton);

    // Check button
    JButton checkButton = new JButton(checking);
    checkButton.setName("optionsCheckButton");
    toolBar.add(checkButton);

    // Reset button
    JButton resetButton = new JButton(resetting);
    resetButton.setName("optionsResetButton");
    toolBar.add(resetButton);

    // Some space
    toolBar.add(Box.createHorizontalStrut(100));

    toolBar.add(new JLabel("Search:"));

    // Back button
    JButton backButton = new JButton(backSearch);
    backButton.setName("optionsBackButton");
    toolBar.add(backButton);

    // Search entry
    searchField = new JTextField();
    searchField.setMaximumSize(new Dimension(200, 28));
    searchField.setName("optionsSearchField");
    searchField.setHorizontalAlignment(JTextField.LEFT);
    toolBar.add(searchField);

    // Forward button
    JButton forwardButton = new JButton(forwardSearch);
    forwardButton.setName("optionsForwardButton");
    toolBar.add(forwardButton);

    // TreeTable
    UnitModel unitModel = new UnitModel();
    unitTreeTable = new UnitTreeTable(unitModel);
    frame.add(new JScrollPane(unitTreeTable), BorderLayout.CENTER);

    // Needed to process user input when RETURN/ENTER is pressed
    toolBar.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke("ENTER"), "EnterAction");
    toolBar.getActionMap()
            .put("EnterAction", forwardSearch);

    // Resources injection
    ResourceMap resource = Application.getInstance()
            .getContext()
            .getResourceMap(getClass());
    resource.injectComponents(frame);

    // Make sure the search entry field gets the focus at creation time
    frame.addWindowListener(
            new WindowAdapter()
    {
        @Override
        public void windowOpened (WindowEvent e)
        {
            searchField.requestFocus();
        }
    });
}
 
源代码20 项目: biojava   文件: SelectPDBPanel.java
private Box getPDBFilePanel(int pos ,JTextField f, JTextField c, JTextField r){

		//JPanel panel = new JPanel();
		//panel.setBorder(BorderFactory.createLineBorder(Color.black));

		JLabel l01 = new JLabel("PDB code ");

		//panel.add(l01);
		Box hBox = Box.createHorizontalBox();
		hBox.add(Box.createGlue());
		hBox.add(l01);

		JLabel l11 = new JLabel(pos + ":");
		f.setMaximumSize(new Dimension(Short.MAX_VALUE,30));
		f.setToolTipText("Provide 4-character PDB code here. Example: 4hhb");
		hBox.add(l11);
		hBox.add(Box.createVerticalGlue());
		hBox.add(f, BorderLayout.CENTER);
		hBox.add(Box.createGlue());

		//panel.add(hBox11);

		//Box hBox21 = Box.createHorizontalBox();
		JLabel l21 = new JLabel("Chain" + pos + ":");
		hBox.add(l21);

		c.setMaximumSize(new Dimension(Short.MAX_VALUE,30));
		//hBox.add(Box.createGlue());
		hBox.add(c, BorderLayout.CENTER);

		String msg1 = "Both chainID and range specification are optional. If both are provided, range has preference.";
		l21.setToolTipText(msg1);
		c.setToolTipText(msg1);

		JLabel rangeL = new JLabel(" Range " + pos + ":");
		hBox.add(Box.createGlue());
		hBox.add(rangeL);
		r.setMaximumSize(new Dimension(Short.MAX_VALUE,30));

		// set help text:
		String msg ="Syntax example: A:407-495,A:582-686";
		rangeL.setToolTipText(msg);
		r.setToolTipText(msg);

		//hBox.add(Box.createGlue());
		hBox.add(r,BorderLayout.CENTER);

		//hBox21.add(Box.createGlue());

		//panel.add(hBox21);



		return hBox;
	}