Java Code Examples for javax.swing.JTextField#setPreferredSize()

The following examples show how to use javax.swing.JTextField#setPreferredSize() . These examples are extracted from open source projects. 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
/**
 * Creates and returns the GUI components for step2.
 *
 * @return
 */
private Component createStep2Panel() {
	JPanel panel = new JPanel();
	panel.setLayout(new GridBagLayout());
	GridBagConstraints gbc = new GridBagConstraints();

	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.weightx = 1;
	gbc.fill = GridBagConstraints.BOTH;
	gbc.insets = new Insets(0, 51, 0, 0);

	codeText = new JTextField();
	codeText.setMinimumSize(new Dimension(80, 33));
	codeText.setPreferredSize(new Dimension(80, 33));
	panel.add(codeText, gbc);

	panel.setBorder(new RoundTitledBorder(2, I18N.getMessage(I18N.getGUIBundle(),
			"gui.dialog.oauth_dialog.copy_code.label"), false));
	return panel;
}
 
Example 2
Source Project: jaamsim   File: GUIFrame.java    License: Apache License 2.0 5 votes vote down vote up
private void addPauseTime(JToolBar mainToolBar, Insets margin) {
	pauseTime = new JTextField("0000-00-00T00:00:00") {
		@Override
		protected void processFocusEvent(FocusEvent fe) {
			if (fe.getID() == FocusEvent.FOCUS_LOST) {
				GUIFrame.this.setPauseTime(this.getText());
			}
			else if (fe.getID() == FocusEvent.FOCUS_GAINED) {
				pauseTime.selectAll();
			}
			super.processFocusEvent( fe );
		}
	};

	pauseTime.setPreferredSize(new Dimension(pauseTime.getPreferredSize().width,
			pauseTime.getPreferredSize().height));

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

	pauseTime.setText("");
	pauseTime.setHorizontalAlignment(JTextField.RIGHT);
	pauseTime.setToolTipText(formatToolTip("Pause Time",
			"Time at which to pause the run, e.g. 3 h, 10 s, etc."));

	mainToolBar.add(pauseTime);
}
 
Example 3
Source Project: swcv   File: MetricsPanel.java    License: MIT License 5 votes vote down vote up
private JTextField createTextField()
{
    JTextField field = new JTextField();
    field.setEnabled(false);
    field.setDisabledTextColor(Color.BLACK);
    field.setPreferredSize(new Dimension(100, 20));
    field.setHorizontalAlignment(JTextField.CENTER);
    return field;
}
 
Example 4
Source Project: binnavi   File: CSettingsPanelBuilder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Adds a text field that is used for setting an option.
 *
 * @param panel The panel the text field is added to.
 * @param textField The text field to add to the panel.
 * @param description The text of the label to be put next to the text field.
 * @param hint Tooltip shown when the user mouse-overs the created hint icon.
 * @param value The initial value of the text field.
 */
public static void addTextField(final JPanel panel, final JTextField textField,
    final String description, final String hint, final String value) {
  Preconditions.checkNotNull(panel, "IE01602: Panel argument can not be null");
  Preconditions.checkNotNull(textField, "IE01603: Text field argument can not be null");
  Preconditions.checkNotNull(description, "IE01604: Description argument can not be null");
  Preconditions.checkNotNull(value, "IE01605: Value argument can not be null");
  textField.setText(value);
  textField.setPreferredSize(new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT));
  addComponent(panel, textField, description, hint);
}
 
Example 5
public IntegerComponent(int inputsize, Integer minimum, Integer maximum) {
  this.minimum = minimum;
  this.maximum = maximum;

  textField = new JTextField();
  textField.setPreferredSize(new Dimension(inputsize, textField.getPreferredSize().height));
  // Add an input verifier if any bounds are specified.
  if (minimum != null || maximum != null) {
    textField.setInputVerifier(new MinMaxVerifier());
  }

  add(textField);
}
 
Example 6
private JTextField getSizedTextField(Dimension preferredSize) {
   JTextField result = new JTextField();
   result.setPreferredSize(preferredSize);
   result.setMinimumSize(preferredSize);
   result.setEditable(false);
   return result;
}
 
Example 7
Source Project: opensim-gui   File: MeasurementSetPanel.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 8
Source Project: jaamsim   File: GUIFrame.java    License: Apache License 2.0 5 votes vote down vote up
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);
	}
 
Example 9
private void initUI() {
	backPanel = new JPanel();
	backPanel.setLayout(new GridLayout(0, 1));

	JPanel widthPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
	widthLabel = new JLabel("Width:");
	widthInput = new JTextField();
	widthInput.setPreferredSize(new Dimension(50, 20));
	widthPanel.add(widthLabel);
	widthPanel.add(widthInput);


	JPanel heightPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
	heightLabel = new JLabel("Height:");
	heightInput = new JTextField();
	heightInput.setPreferredSize(new Dimension(50, 20));
	heightPanel.add(heightLabel);
	heightPanel.add(heightInput);

	JPanel foodPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
	foodRateLabel = new JLabel("Food Rate: (0-100)");
	foodRateInput = new JTextField();
	foodRateInput.setPreferredSize(new Dimension(50, 20));
	foodPanel.add(foodRateLabel);
	foodPanel.add(foodRateInput);

	backPanel.add(widthPanel);
	backPanel.add(heightPanel);
	backPanel.add(foodPanel);

	createButton = new JButton("Create World");
	createButton.addActionListener(this);

	backPanel.add(createButton);

	setContentPane(backPanel);
}
 
Example 10
private void initUI() {
	backPanel = new JPanel();
	backPanel.setLayout(new GridLayout(0, 1));
	
	JPanel[] panels = new JPanel[9];
	for (int k = 0; k < panels.length; k++) {
		panels[k] = new JPanel(new FlowLayout(FlowLayout.LEFT));
	}
	
	amountInput = new JTextField();
	amountInput.setPreferredSize(new Dimension(50, 20));
	maxEnergyInput = new JTextField();
	maxEnergyInput.setPreferredSize(new Dimension(50, 20));
	maxLifeInput = new JTextField();
	maxLifeInput.setPreferredSize(new Dimension(50, 20));
	speedInput = new JTextField();
	speedInput.setPreferredSize(new Dimension(50, 20));
	visionRangeInput = new JTextField();
	visionRangeInput.setPreferredSize(new Dimension(50, 20));
	maleRationInput = new JTextField();
	maleRationInput.setPreferredSize(new Dimension(50, 20));
	matingEnergyNeededInput = new JTextField();
	matingEnergyNeededInput.setPreferredSize(new Dimension(50, 20));
	breedLengthInput = new JTextField();
	breedLengthInput.setPreferredSize(new Dimension(50, 20));
	breedProgressSpeedInput = new JTextField();
	breedProgressSpeedInput.setPreferredSize(new Dimension(50, 20));
	
	maxEnergyVarianceInput = new JTextField();
	maxEnergyVarianceInput.setPreferredSize(new Dimension(50, 20));
	maxLifeVarianceInput = new JTextField();
	maxLifeVarianceInput.setPreferredSize(new Dimension(50, 20));
	speedVarianceInput = new JTextField();
	speedVarianceInput.setPreferredSize(new Dimension(50, 20));
	visionRangeVarianceInput = new JTextField();
	visionRangeVarianceInput.setPreferredSize(new Dimension(50, 20));
	matingEnergyNeededVarianceInput = new JTextField();
	matingEnergyNeededVarianceInput.setPreferredSize(new Dimension(50, 20));
	breedLengthVarianceInput = new JTextField();
	breedLengthVarianceInput.setPreferredSize(new Dimension(50, 20));
	breedProgressSpeedVarianceInput = new JTextField();
	breedProgressSpeedVarianceInput.setPreferredSize(new Dimension(50, 20));
	
	panels[0].add(new JLabel("Amount:"));
	panels[0].add(amountInput);
	
	panels[1].add(new JLabel("Max Energy:"));
	panels[1].add(maxEnergyInput);
	panels[1].add(maxEnergyVarianceInput);
	
	panels[2].add(new JLabel("Max Life:"));
	panels[2].add(maxLifeInput);
	panels[2].add(maxLifeVarianceInput);
	
	panels[3].add(new JLabel("Speed:"));
	panels[3].add(speedInput);
	panels[3].add(speedVarianceInput);
	
	panels[4].add(new JLabel("Vision Range:"));
	panels[4].add(visionRangeInput);
	panels[4].add(visionRangeVarianceInput);
	
	panels[5].add(new JLabel("Male Ratio: (0-100)"));
	panels[5].add(maleRationInput);
	
	panels[6].add(new JLabel("Mating Energy Needed:"));
	panels[6].add(matingEnergyNeededInput);
	panels[6].add(matingEnergyNeededVarianceInput);
	
	panels[7].add(new JLabel("Breed Length:"));
	panels[7].add(breedLengthInput);
	panels[7].add(breedLengthVarianceInput);
	
	panels[8].add(new JLabel("Breed Progress Speed:"));
	panels[8].add(breedProgressSpeedInput);
	panels[8].add(breedProgressSpeedVarianceInput);

	for (JPanel p : panels) {
		backPanel.add(p);
	}
	
	createButton = new JButton("Create Creatures");
	createButton.addActionListener(this);

	backPanel.add(createButton);

	setContentPane(backPanel);
}
 
Example 11
public ToadDataPanel(DisplayMode displayMode)
{
	super(displayMode);
	

	comboBoxPopulation = new JComboBox(); 
	for (Object item : Locale.dropDownPopulations)
		comboBoxPopulation.addItem(item);	
	comboBoxPopulation.setPreferredSize(new Dimension(iw, lh));
	
	textFieldSize1 = new JTextField("");   textFieldSize1.setPreferredSize(new Dimension(iw, 30)); textFieldSize1.setBorder(BorderFactory.createLineBorder(Color.BLACK));
	textFieldSize2 = new JTextField("");   textFieldSize2.setPreferredSize(new Dimension(iw, 30)); textFieldSize2.setBorder(BorderFactory.createLineBorder(Color.BLACK));
	textFieldWeight = new JTextField("");   textFieldWeight.setPreferredSize(new Dimension(iw, 30)); textFieldWeight.setBorder(BorderFactory.createLineBorder(Color.BLACK));
	textFieldTotal = new JTextField("");   textFieldTotal.setPreferredSize(new Dimension(iw, 30)); textFieldTotal.setBorder(BorderFactory.createLineBorder(Color.BLACK));
	textFieldTotal.setEditable(false);
	
	labelPopulation =     GUISettings.getDefaultLabel(Locale.labelPopulation, lw, lh, a, va);  
	labelSize1 =          GUISettings.getDefaultLabel(Locale.labelSize1, lw, lh, a, va);  		
	labelSize2 =          GUISettings.getDefaultLabel(Locale.labelSize2, lw, lh, a, va);  		
	labelSizeTotal =      GUISettings.getDefaultLabel(Locale.labelSizeTotal, lw, lh, a, va);  		
	labelWeight =         GUISettings.getDefaultLabel(Locale.labelWeight, lw, lh, a, va);  		

	JPanel panelSize1                   = new JPanel(new FlowLayout(orientation)); 
	JPanel panelSize2                   = new JPanel(new FlowLayout(orientation)); 
	JPanel panelSizeTotal               = new JPanel(new FlowLayout(orientation)); 
	JPanel panelWeight                  = new JPanel(new FlowLayout(orientation)); 
	JPanel panelPopulation              = new JPanel(new FlowLayout(orientation)); 
	
	if (currentDisplayMode.equals(DisplayMode.vertical_align_left))
	{
		panelSize1.add(textFieldSize1);		
		panelSize1.add(labelSize1);
		panelSize2.add(textFieldSize2);		
		panelSize2.add(labelSize2);
		panelSizeTotal.add(textFieldTotal);		
		panelSizeTotal.add(labelSizeTotal);
		panelWeight.add(textFieldWeight);		
		panelWeight.add(labelWeight);
		panelPopulation.add(comboBoxPopulation);
		panelPopulation.add(labelPopulation);
	}
	else
	{
		panelSize1.add(labelSize1);
		panelSize1.add(textFieldSize1);		
		panelSize2.add(labelSize2);
		panelSize2.add(textFieldSize2);		
		panelSizeTotal.add(labelSizeTotal);
		panelSizeTotal.add(textFieldTotal);		
		panelWeight.add(labelWeight);
		panelWeight.add(textFieldWeight);		
		panelPopulation.add(labelPopulation);
		panelPopulation.add(comboBoxPopulation);
	}
	
	inputLabels.add(labelSize1);
	inputLabels.add(labelSize2);
	inputLabels.add(labelSizeTotal);
	inputLabels.add(labelWeight);
	inputLabels.add(labelPopulation);

	JPanel toadDataPanel = new JPanel();
	toadDataPanel.setLayout(new BoxLayout(toadDataPanel, BoxLayout.Y_AXIS));
	toadDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black, 1), Locale.labelToadData));
	
	toadDataPanel.add(panelPopulation);
	toadDataPanel.add(panelSize1);
	toadDataPanel.add(panelSize2);
	toadDataPanel.add(panelSizeTotal);
	toadDataPanel.add(panelWeight);
	JPanel placeholder = new JPanel();
	toadDataPanel.add(placeholder);
	
	
	dataPanel.add(toadDataPanel);
	
}
 
Example 12
private JPanel analysisChain() {
  JPanel panel = new JPanel(new GridBagLayout());
  panel.setOpaque(false);

  GridBagConstraints c = new GridBagConstraints();
  c.fill = GridBagConstraints.HORIZONTAL;
  c.insets = new Insets(5, 5, 5, 5);

  c.gridx = 0;
  c.gridy = 0;
  c.weightx = 0.1;
  c.weighty = 0.5;
  panel.add(new JLabel(MessageUtils.getLocalizedMessage("analysis.dialog.chain.label.charfilters")), c);

  String[] charFilters = analyzer.getCharFilterFactories().stream().map(f -> CharFilterFactory.findSPIName(f.getClass())).toArray(String[]::new);
  JList<String> charFilterList = new JList<>(charFilters);
  charFilterList.setVisibleRowCount(charFilters.length == 0 ? 1 : Math.min(charFilters.length, 5));
  c.gridx = 1;
  c.gridy = 0;
  c.weightx = 0.5;
  c.weighty = 0.5;
  panel.add(new JScrollPane(charFilterList), c);

  c.gridx = 0;
  c.gridy = 1;
  c.weightx = 0.1;
  c.weighty = 0.1;
  panel.add(new JLabel(MessageUtils.getLocalizedMessage("analysis.dialog.chain.label.tokenizer")), c);

  String tokenizer = TokenizerFactory.findSPIName(analyzer.getTokenizerFactory().getClass());
  JTextField tokenizerTF = new JTextField(tokenizer);
  tokenizerTF.setColumns(30);
  tokenizerTF.setEditable(false);
  tokenizerTF.setPreferredSize(new Dimension(300, 25));
  tokenizerTF.setBorder(BorderFactory.createLineBorder(Color.gray));
  c.gridx = 1;
  c.gridy = 1;
  c.weightx = 0.5;
  c.weighty = 0.1;
  panel.add(tokenizerTF, c);

  c.gridx = 0;
  c.gridy = 2;
  c.weightx = 0.1;
  c.weighty = 0.5;
  panel.add(new JLabel(MessageUtils.getLocalizedMessage("analysis.dialog.chain.label.tokenfilters")), c);

  String[] tokenFilters = analyzer.getTokenFilterFactories().stream().map(f -> TokenFilterFactory.findSPIName(f.getClass())).toArray(String[]::new);
  JList<String> tokenFilterList = new JList<>(tokenFilters);
  tokenFilterList.setVisibleRowCount(tokenFilters.length == 0 ? 1 : Math.min(tokenFilters.length, 5));
  tokenFilterList.setMinimumSize(new Dimension(300, 25));
  c.gridx = 1;
  c.gridy = 2;
  c.weightx = 0.5;
  c.weighty = 0.5;
  panel.add(new JScrollPane(tokenFilterList), c);

  return panel;
}
 
Example 13
private JTextField createPathField() {
	JTextField newTextField = new JTextField();
	newTextField.setPreferredSize(new JTextField(String.join("", Collections.nCopies(50, "_"))).getPreferredSize());
	return newTextField;
}
 
Example 14
private void createContent() {
    Container cp = (JComponent) getContentPane();

    final JPanel urlPanel = new JPanel(new BorderLayout(0, 12));
    urlPanel.setBorder(new EmptyBorder(6, 12, 12, 12));
    final JPanel bottomPanel = new JPanel(new BorderLayout());

    statusBar = new JLabel(" ", JLabel.CENTER);

    final Font normalLabelFont = statusBar.getFont();
    Font boldLabelFont = normalLabelFont.deriveFont(Font.BOLD);
    final Font smallLabelFont = normalLabelFont.deriveFont(normalLabelFont.getSize2D() - 1);
    //TODO: is this fine or should it be padded like original?
    final URL iconURL = GuiMain.class.getResource("/icon/wildfly_logo.png");
    final Image logo = Toolkit.getDefaultToolkit().getImage(iconURL);
    final Icon icon = new ImageIcon(logo);
    final JLabel mastheadLabel = new JLabel(icon);

    cp.add(mastheadLabel, NORTH);
    cp.add(urlPanel, CENTER);
    cp.add(bottomPanel, SOUTH);

    tfURL = new JTextField();
    tfURL.getDocument().addDocumentListener(new UrlDocumentListener(tfURL));

    tfURL.setPreferredSize(tfURL.getPreferredSize());

    final JPanel tfPanel = new JPanel(new BorderLayout());
    urlPanel.add(tfPanel, CENTER);

    tfPanel.add(tfURL, NORTH);

    final JLabel remoteMessageLabel = new JLabel(HINT_CONNECT);
    remoteMessageLabel.setFont(smallLabelFont);
    remoteMessageLabel.setForeground(hintTextColor);
    tfPanel.add(remoteMessageLabel, CENTER);

    final JPanel userPwdPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    userPwdPanel.setBorder(new EmptyBorder(12, 0, 0, 0)); // top padding

    int tfWidth = IS_WIN ? 12 : 8;

    tfUserName = new JTextField(tfWidth);


    JPanel lc;
    lc = new Labeled(TEXT_USERNAME,boldLabelFont, tfUserName);
    userPwdPanel.add(lc);

    tfPassword = new JPasswordField(tfWidth);
    // Heights differ, so fix here
    tfPassword.setPreferredSize(tfUserName.getPreferredSize());

    lc = new Labeled(TEXT_PASSWORD, boldLabelFont, tfPassword);
    lc.setBorder(new EmptyBorder(0, 12, 0, 0)); // Left padding
    lc.setFont(boldLabelFont);
    userPwdPanel.add(lc);

    tfPanel.add(userPwdPanel, SOUTH);

    final JButton connectButton = new JButton(this.actionConnect);
    connectButton.setToolTipText(HINT_CONNECT_BUTTON);

    final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    buttonPanel.setBorder(new EmptyBorder(12, 12, 2, 12));
    buttonPanel.add(connectButton);
    bottomPanel.add(buttonPanel, NORTH);
    bottomPanel.add(statusBar, SOUTH);
    this.pack();
}
 
Example 15
void addComboField(JPanel parent, String labelText, String propertyName, List<String> values) {
    JLabel jLabel = new JLabel(labelText);
    parent.add(jLabel);

    PropertyDescriptor propertyDescriptor = propertyContainer.getDescriptor(propertyName);
    propertyDescriptor.setNotEmpty(true);

    values.sort(Comparator.naturalOrder());

    propertyDescriptor.setValueSet(new ValueSet(values.toArray()));
    PropertyEditor editor = PropertyEditorRegistry.getInstance().findPropertyEditor(propertyDescriptor);
    JComponent editorComp = editor.createEditorComponent(propertyDescriptor, bindingContext);
    if (editorComp instanceof JComboBox) {
        JComboBox comboBox = (JComboBox)editorComp;
        comboBox.setEditable(true);
    }
    editorComp.setMaximumSize(new Dimension(editorComp.getMaximumSize().width, controlHeight));

    customMenuLocation = new JTextField();
    customMenuLocation.setInputVerifier(new RequiredFieldValidator(Bundle.MSG_Empty_MenuLocation_Text()));
    customMenuLocation.setEnabled(false);

    JPanel subPanel = new JPanel(new SpringLayout());
    subPanel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    JRadioButton rbExistingMenu = new JRadioButton(Bundle.CTL_Label_RadioButton_ExistingMenus(), true);
    rbMenuNew = new JRadioButton(Bundle.CTL_Label_RadioButton_NewMenu());
    ButtonGroup rbGroup = new ButtonGroup();
    rbGroup.add(rbExistingMenu);
    rbGroup.add(rbMenuNew);
    // this radio button should be able to capture focus even when the validator of the rbMenuNew says otherwise
    rbExistingMenu.setVerifyInputWhenFocusTarget(false);
    rbExistingMenu.addItemListener(e -> {
        editorComp.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
        customMenuLocation.setEnabled(e.getStateChange() == ItemEvent.DESELECTED);
    });
    subPanel.add(rbExistingMenu);
    subPanel.add(rbMenuNew);
    jLabel.setLabelFor(editorComp);
    subPanel.add(editorComp);
    subPanel.add(customMenuLocation);

    Dimension dimension = new Dimension(parent.getWidth() / 2, controlHeight);
    editorComp.setPreferredSize(dimension);
    customMenuLocation.setPreferredSize(dimension);

    subPanel.setPreferredSize(new Dimension(subPanel.getWidth(), (int)(2.5 * controlHeight)));
    subPanel.setMaximumSize(new Dimension(subPanel.getWidth(), (int) (2.5 * controlHeight)));

    makeCompactGrid(subPanel, 2, 2, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING, DEFAULT_PADDING);

    parent.add(subPanel);
}
 
Example 16
TwoDBottomPanel(TwoDVisualizerWindow masterFrame, RawDataFile dataFile, ParameterSet parameters) {

    this.dataFile = dataFile;
    this.masterFrame = masterFrame;

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

    setBackground(Color.white);
    setBorder(new EmptyBorder(5, 5, 5, 0));

    add(Box.createHorizontalGlue());

    GUIUtils.addLabel(this, "Show: ", SwingConstants.RIGHT);

    thresholdCombo = new JComboBox<Object>(PeakThresholdMode.values());
    thresholdCombo.setBackground(Color.white);
    thresholdCombo.setFont(smallFont);
    thresholdCombo.addActionListener(this);
    add(thresholdCombo);

    JPanel peakThresholdPanel = new JPanel();
    peakThresholdPanel.setBackground(Color.white);
    peakThresholdPanel.setLayout(new BoxLayout(peakThresholdPanel, BoxLayout.X_AXIS));

    GUIUtils.addLabel(peakThresholdPanel, "Value: ", SwingConstants.RIGHT);

    peakTextField = new JTextField();
    peakTextField.setPreferredSize(new Dimension(50, 15));
    peakTextField.setFont(smallFont);
    peakTextField.addActionListener(this);
    peakThresholdPanel.add(peakTextField);
    add(peakThresholdPanel);

    GUIUtils.addLabel(this, " from feature list: ", SwingConstants.RIGHT);

    peakListSelector = new JComboBox<PeakList>();
    peakListSelector.setBackground(Color.white);
    peakListSelector.setFont(smallFont);
    peakListSelector.addActionListener(this);
    peakListSelector.setActionCommand("PEAKLIST_CHANGE");
    add(peakListSelector);

    thresholdSettings = parameters.getParameter(TwoDVisualizerParameters.peakThresholdSettings);

    thresholdCombo.setSelectedItem(thresholdSettings.getMode());

    add(Box.createHorizontalStrut(10));

    add(Box.createHorizontalGlue());

  }
 
Example 17
private JTextField createPathField() {
	JTextField newTextField = new JTextField();
	newTextField.setPreferredSize(new JTextField(String.join("", Collections.nCopies(50, "_"))).getPreferredSize());
	return newTextField;
}
 
Example 18
private void init() {
	setLayout(new GridBagLayout());  
			
	JLabel titleLabel = new JLabel(I18NSupport.getString("wizard.panel.display.title"));
	titleField = new JTextField();
	titleField.setPreferredSize(txtDim);
	titleField.setMinimumSize(txtDim);				
	
	shouldRise = new JCheckBox(I18NSupport.getString("wizard.panel.display.shouldRise"));
	shadow = new JCheckBox(I18NSupport.getString("wizard.panel.display.shadow"));
	
	Component[] titleColor = createColorField(I18NSupport.getString("wizard.panel.display.title.color"), Color.BLACK);		
	titleColorField = (JTextField)titleColor[1];			
	
	Component[] valueColor = createColorField(I18NSupport.getString("wizard.panel.display.value.color"), Color.BLUE);		
	valueColorField = (JTextField)valueColor[1];	
	
	Component[] previousColor = createColorField(I18NSupport.getString("wizard.panel.display.previous.color"), Color.LIGHT_GRAY);		
	previousColorField = (JTextField)previousColor[1];		
	
	Component[] backgroundColor = createColorField(I18NSupport.getString("wizard.panel.display.background.color"), Color.WHITE);		
	backgroundColorField = (JTextField)backgroundColor[1];		
					
	JLabel imageLabel = new JLabel(ImageUtil.getImageIcon("display_main"));
	imageLabel.setPreferredSize(new Dimension(280, 170));
	
	add(titleLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
	add(titleField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
	add(imageLabel, new GridBagConstraints(3, 0, 1, 8, 1.0, 1.0,  GridBagConstraints.CENTER, 
			GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));		
	add(shouldRise, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
	add(shadow, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
	add(titleColor[0], new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
	add(titleColorField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
	add(titleColor[2], new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
	add(valueColor[0], new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
	add(valueColorField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
	add(valueColor[2], new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
	add(previousColor[0], new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
	add(previousColorField, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
	add(previousColor[2], new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
	add(backgroundColor[0], new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
	add(backgroundColorField, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
	add(backgroundColor[2], new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0,  GridBagConstraints.WEST, 
			GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0));
}
 
Example 19
Source Project: bigtable-sql   File: ColumnListDialog.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Creates the UI for this dialog.
 */
private void init(String[] columnNames) {
    super.setModal(true);        
    if (_mode == DROP_COLUMN_MODE) {
        setTitle(i18n.DROP_TITLE);
    } 
    if (_mode == MODIFY_COLUMN_MODE) {
        setTitle(i18n.MODIFY_TITLE);
    }
    if (_mode == ADD_PRIMARY_KEY_MODE) {
        setTitle(i18n.PRIMARY_KEY_TITLE);
    }
    if (_mode == DROP_PRIMARY_KEY_MODE) {
        setTitle(i18n.DROP_PRIMARY_KEY_TITLE);
    }
    setSize(425, 250);
    EmptyBorder border = new EmptyBorder(new Insets(5,5,5,5));
    Dimension mediumField = new Dimension(126, 20);
    
    JPanel pane = new JPanel();
    pane.setLayout(new GridBagLayout());
    pane.setBorder(new EmptyBorder(10,0,0,30));

    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = -1;

    // Table name
    tableNameLabel = getBorderedLabel(i18n.TABLE_NAME_LABEL, border);
    pane.add(tableNameLabel, getLabelConstraints(c));
    
    tableNameTextField = new JTextField();
    tableNameTextField.setPreferredSize(mediumField);
    tableNameTextField.setEditable(false);
    pane.add(tableNameTextField, getFieldConstraints(c));
            
    // Primary Key name
    if (_mode == ADD_PRIMARY_KEY_MODE
            || _mode == DROP_PRIMARY_KEY_MODE) {
        primaryKeyNameLabel = new JLabel(i18n.PRIMARY_KEY_NAME_LABEL);
        pane.add(primaryKeyNameLabel, getLabelConstraints(c));
        
        primaryKeyNameTF = new JTextField();
        primaryKeyNameTF.setPreferredSize(mediumField);
        if (_mode == ADD_PRIMARY_KEY_MODE) {
            primaryKeyNameTF.setEditable(true);
        } else {
            primaryKeyNameTF.setEditable(false);
        }
        pane.add(primaryKeyNameTF, getFieldConstraints(c));
    }
    
    // Column list        
    columnListLabel = getBorderedLabel(i18n.COLUMN_NAME_LABEL, border);
    columnListLabel.setVerticalAlignment(JLabel.NORTH);
    pane.add(columnListLabel, getLabelConstraints(c));
    
    columnList = new JList(columnNames);
    columnList.addListSelectionListener(new ColumnListSelectionListener());

    JScrollPane sp = new JScrollPane(columnList);
    c = getFieldConstraints(c);
    c.weightx = 1;
    c.weighty = 1;        
    c.fill=GridBagConstraints.BOTH;
    pane.add(sp, c);
            
    Container contentPane = super.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(pane, BorderLayout.CENTER);
    
    contentPane.add(getButtonPanel(), BorderLayout.SOUTH);
}
 
Example 20
Source Project: jaamsim   File: GUIFrame.java    License: Apache License 2.0 4 votes vote down vote up
private void addFontSelector(JToolBar buttonBar, Insets margin) {

		font = new JTextField("");
		font.setEditable(false);
		font.setHorizontalAlignment(JTextField.CENTER);
		font.setPreferredSize(new Dimension(120, fileSave.getPreferredSize().height));
		font.setToolTipText(formatToolTip("Font", "Sets the font for the text."));
		buttonBar.add(font);

		fontSelector = new JButton(new ImageIcon(
				GUIFrame.class.getResource("/resources/images/dropdown.png")));
		fontSelector.setMargin(margin);
		fontSelector.setFocusPainted(false);
		fontSelector.setRequestFocusEnabled(false);
		fontSelector.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed( ActionEvent event ) {
				if (!(selectedEntity instanceof TextEntity))
					return;
				final TextEntity textEnt = (TextEntity) selectedEntity;
				final String presentFontName = textEnt.getFontName();
				ArrayList<String> valuesInUse = GUIFrame.getFontsInUse(sim);
				ArrayList<String> choices = TextModel.validFontNames;
				PreviewablePopupMenu fontMenu = new PreviewablePopupMenu(presentFontName,
						valuesInUse, choices, true) {

					@Override
					public void setValue(String str) {
						font.setText(str);
						String name = Parser.addQuotesIfNeeded(str);
						KeywordIndex kw = InputAgent.formatInput("FontName", name);
						InputAgent.storeAndExecute(new KeywordCommand(selectedEntity, kw));
					}

				};
				fontMenu.show(font, 0, font.getPreferredSize().height);
				controlStartResume.requestFocusInWindow();
			}
		});

		buttonBar.add(fontSelector);
	}