javax.swing.JComboBox#setEditable ( )源码实例Demo

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

源代码1 项目: netbeans   文件: EnterWSDLUrlPanel.java
private void initComponents() {
    inputLabel = new JLabel(NbBundle.getMessage(EnterWSDLUrlPanel.class, "LBL_Input_WSDL_Url"));
    wsdlURLComboBox = new JComboBox();
    wsdlURLComboBox.setEditable(true);
    
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(6,6,6,6);
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    add(inputLabel, gbc);
    gbc.gridy = 1;
    gbc.weightx = 2.0;
    add(wsdlURLComboBox, gbc);
}
 
源代码2 项目: chipster   文件: ImportSettingsAccessory.java
public ImportSettingsAccessory(JFileChooser fileChooser) {

		this.setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		c.anchor = GridBagConstraints.NORTHWEST;
		c.fill = GridBagConstraints.HORIZONTAL;
		c.weightx = 1;
		
		c.gridx = 0;
		c.gridy = 0;
		c.insets.set(0, 5, 0, 0);
		JLabel folderNameLabel = new JLabel("Insert in folder");
		this.add(folderNameLabel, c);

		c.gridy++;
		Set<String> folderNameList = ImportUtils.getFolderNames(true);
		folderNameCombo = new JComboBox(folderNameList.toArray());
		folderNameCombo.setEditable(true);
		this.add(folderNameCombo, c);

		c.gridy++;
		c.insets.set(10, 5, 0, 0);
		c.weighty = 1;
		skipCheckBox = new JCheckBox(VisualConstants.getImportDirectlyText());
		if (!Session.getSession().getApplication().isStandalone()) {
			skipCheckBox.setSelected(true);
		} else {
			skipCheckBox.setSelected(false);
		}
		
		this.add(skipCheckBox, c);
		
		// listen to file chooser for events that are related to this accessory
		fileChooser.addActionListener(this);
	}
 
源代码3 项目: cropplanning   文件: CPSCardPanel.java
public CPSCardPanel( String[] titles,
                       JPanel[] panels ) {

    this.setLayout( new BoxLayout(this, BoxLayout.PAGE_AXIS ));
    this.setBorder( BorderFactory.createEtchedBorder() );


    cb = new JComboBox(titles);
    cb.setEditable(false);
    cb.addItemListener(this);
    cb.setMaximumSize( cb.getPreferredSize() );
    this.add( cb );

    Dimension dim = new Dimension();
    Dimension jpDim;

    cards = new JPanel( new CardLayout() );
    for ( int i = 0; i < panels.length; i++ ) {
      jpDim = panels[i].getPreferredSize();
      // make sure each panel can't expand
      //panels[i].setMaximumSize( jpDim );

      // find out biggest panel
      if ( jpDim.getWidth() > dim.getWidth() )
        dim.setSize( jpDim.getWidth()+10, dim.getHeight() );
      if ( jpDim.getHeight() > dim.getHeight() )
        dim.setSize( dim.getWidth(), jpDim.getHeight() );

      cards.add( panels[i], titles[i] );
    }
    
    cards.setPreferredSize(dim);
//    this.setMaximumSize(dim);
    this.add( cards );

  }
 
源代码4 项目: netbeans   文件: RunPortBindingsVisual.java
/**
 * Creates new form RunNetworkVisual
 */
public RunPortBindingsVisual(DockerImageDetail info) {
    initComponents();
    this.info = info;

    addExposedButton.setEnabled(info != null && !info.getExposedPorts().isEmpty());
    portMappingTable.setModel(model);
    UiUtils.configureRowHeight(portMappingTable);

    TableColumn typeColumn = portMappingTable.getColumnModel().getColumn(0);
    JComboBox typeCombo = new JComboBox(ExposedPort.Type.values());
    typeColumn.setCellEditor(new DefaultCellEditor(typeCombo));
    typeColumn.setPreferredWidth(typeColumn.getPreferredWidth() / 2);

    TableColumn portColumn = portMappingTable.getColumnModel().getColumn(2);
    portColumn.setCellRenderer(new CellRenderer("<random>", false));

    TableColumn addressColumn = portMappingTable.getColumnModel().getColumn(3);
    JComboBox addressCombo = new JComboBox(UiUtils.getAddresses(false, false).toArray());
    addressCombo.setEditable(true);
    addressColumn.setCellEditor(new DefaultCellEditor(addressCombo));
    addressColumn.setCellRenderer(new CellRenderer("<any>", false));
    addressColumn.setPreferredWidth(addressColumn.getPreferredWidth() * 2);

    portMappingTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    model.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            changeSupport.fireChange();
        }
    });
}
 
源代码5 项目: wandora   文件: ExcelExtractorUI.java
public void open(Collection<String> sheets, Collection<String> extractors) {
    JPanel sheetSelectors = new JPanel();
    sheetSelectors.setLayout(new GridBagLayout());
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    
    
    comboboxes = new ArrayList();
    
    for(String sheet : sheets) {
        JLabel label = new SimpleLabel(sheet);
        gridBagConstraints.gridx = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 0.0;
        gridBagConstraints.insets = new Insets(6,6,6,6);
        sheetSelectors.add(label, gridBagConstraints);
        JComboBox combobox = new SimpleComboBox(extractors);
        combobox.setEditable(false);
        gridBagConstraints.gridx = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new Insets(6,0,6,6);
        sheetSelectors.add(combobox, gridBagConstraints);
        comboboxes.add(combobox);
    }
    scrollPane.setViewportView(sheetSelectors);
    
    Wandora wandora = Wandora.getWandora();
    myDialog = new JDialog(wandora, true);
    myDialog.setTitle("Select extractor for each Excel sheet");
    myDialog.setSize(500, 300);
    myDialog.add(this);
    wandora.centerWindow(myDialog);
    myDialog.setVisible(true);
}
 
源代码6 项目: jdal   文件: AutoCompletionListener.java
/**
 * Add the AutoCompletionListener to a JComboBox
 * @param combo the combo to add on.
 */
public void listenOn(JComboBox combo) {
	if (this.combo != null) {
		this.combo.getEditor().getEditorComponent().removeKeyListener(this);
	}
	
	this.combo = combo;
	combo.setEditable(true);
	combo.getEditor().getEditorComponent().addKeyListener(this);
}
 
源代码7 项目: PIPE   文件: PipeApplicationBuilder.java
/**
 * Adds a zoom combo box to the toolbar
 *
 * @param toolBar the JToolBar to add the button to
 * @param action  the action that the ZoomComboBox performs
 * @param view application view 
 */
private void addZoomComboBox(JToolBar toolBar, Action action, String[] zoomExamples, PipeApplicationView view) {
    Dimension zoomComboBoxDimension = new Dimension(65, 28);
    JComboBox<String> zoomComboBox = new JComboBox<>(zoomExamples);
    zoomComboBox.setEditable(true);
    zoomComboBox.setSelectedItem("100%");
    zoomComboBox.setMaximumRowCount(zoomExamples.length);
    zoomComboBox.setMaximumSize(zoomComboBoxDimension);
    zoomComboBox.setMinimumSize(zoomComboBoxDimension);
    zoomComboBox.setPreferredSize(zoomComboBoxDimension);
    zoomComboBox.setAction(action);
    view.registerZoom(zoomComboBox);
    toolBar.add(zoomComboBox);
}
 
源代码8 项目: Llunatic   文件: CostManagerEditor.java
@Override
    @SuppressWarnings("unchecked")
    public InplaceEditor getInplaceEditor() {
        if (ed == null) {
            Collection<String> costManager = costManagerProvider.getAll();
//            JComboBox comboBox = new JComboBox<ICostManager>(costManager.toArray(new ICostManager[costManager.size()]));
            JComboBox comboBox = new JComboBox(costManager.toArray(new String[costManager.size()]));
            comboBox.setEditable(false);
            ed = new InplaceComboBoxEditor(comboBox);
        }
        return ed;
    }
 
源代码9 项目: netbeans   文件: TargetMappingPanel.java
private void initAntTargetEditor(List<String> targets) {
    JComboBox combo = new JComboBox();
    combo.setEditable(true);
    for (String target : targets) {
        combo.addItem(target);
    }
    customTargets.setDefaultEditor(JComboBox.class, new DefaultCellEditor(combo));
}
 
源代码10 项目: wpcleaner   文件: OptionsPanel.java
protected JComboBox<String> createJComboBox(
    ConfigurationValueString property,
    Vector<String> items) {
  if (property == null) {
    return null;
  }
  JComboBox<String> combo = new JComboBox<String>(items);
  combo.setEditable(false);
  Configuration config = Configuration.getConfiguration();
  String value = config.getString(null, property);
  combo.setSelectedItem(value);
  stringValues.put(property, combo);
  return combo;
}
 
@Override
public TableCellEditor getCellEditor(int row, int column) {
	JComboBox<String> typeBox = new JComboBox<>(Attributes.KNOWN_ATTRIBUTE_TYPES);
	typeBox.setEditable(true);
	typeBox.setBackground(javax.swing.UIManager.getColor("Table.cellBackground"));
	return new DefaultCellEditor(typeBox);
}
 
源代码12 项目: netbeans   文件: GUIRegistrationPanel.java
private void setEditable(final JComboBox combo) {
    combo.setEditable(true);
    if (combo.getEditor().getEditorComponent() instanceof JTextField) {
        JTextField txt = (JTextField) combo.getEditor().getEditorComponent();
        // XXX check if there are not multiple (--> redundant) listeners
        txt.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() {
            public void insertUpdate(DocumentEvent e) {
                if (!UIUtil.isWaitModel(combo.getModel())) {
                    checkValidity();
                }
            }
        });
    }
}
 
public void updateEditorsAndRenderers() {
	if (editors != null) {
		editors.clear();
		int numberOfRows = getModel().getRowCount();
		for (int i = 0; i < numberOfRows; i++) {
			JComboBox<String> comboBox = new JComboBox<>(ROLE_NAMES);
			comboBox.setEditable(true);
			RoleSelectionEditor editor = new RoleSelectionEditor(comboBox);
			editors.add(editor);
		}
	}
}
 
源代码14 项目: AndroidDBvieweR   文件: CreateTableDialog.java
/**
 * Creates new form DatabaseBuilderFrame
 * @param frame
 * @param modal
 */
public CreateTableDialog(Frame frame, boolean modal) {
    super(frame, modal);
    this.mainFrame = (MainFrame) frame;
    initComponents();
    setLocationRelativeTo(null);
    setMinimumSize(new Dimension(700, 540));
    databaseConfigDefaultTable = (DefaultTableModel) databaseConfigTable.getModel();
    databaseTableColumnModel = databaseConfigTable.getColumnModel();

    columnHash = databaseTableColumnModel.getColumn(0);
    columnName = databaseTableColumnModel.getColumn(1);
    columnType = databaseTableColumnModel.getColumn(2);
    Object[] fieldTypes = new Object[]{
        "INTEGER",
        "VARCHAR",
        "DECIMAL",
        "TEXT",
        "DATETIME",
        "TINYINT",
        "BLOB",
        "SMALLINT",
        "MEDIUMINT",
        "BIGINT",
        "CHARACTER",
        "REAL",
        "DOUBLE",
        "FLOAT",
        "BOOLEAN",
        "DATE"
    };
    final JComboBox fieldTypeComboBox = new JComboBox(fieldTypes);
    fieldTypeComboBox.setEditable(false);
    fieldTypeComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            String selectedItem = fieldTypeComboBox.getSelectedItem().toString();
            if (Boolean.parseBoolean(databaseConfigTable.getValueAt(databaseConfigTable.getSelectedRow(), 5).toString()) && !(selectedItem.equals("INTEGER") || selectedItem.equals("INTEGER"))) {
                databaseConfigTable.setValueAt(false, databaseConfigTable.getSelectedRow(), 5);
            }
        }
    });
    columnType.setCellEditor(new DefaultCellEditor(fieldTypeComboBox));
    columnPrimaryKey = databaseTableColumnModel.getColumn(3);
    columnNotNull = databaseTableColumnModel.getColumn(4);
    columnAutoIncrement = databaseTableColumnModel.getColumn(5);
    columnUnion = databaseTableColumnModel.getColumn(6);
    columnDefault = databaseTableColumnModel.getColumn(7);

}
 
源代码15 项目: chipster   文件: CreateFromTextDialog.java
public CreateFromTextDialog(ClientApplication clientApplication) {
    super(Session.getSession().getFrames().getMainFrame(), true);

    this.setTitle("Create dataset from text");
    this.setModal(true);
    
    // Layout
    GridBagConstraints c = new GridBagConstraints();
    this.setLayout(new GridBagLayout());
    
    // Name label
    nameLabel = new JLabel("Filename");
    c.anchor = GridBagConstraints.WEST;
    c.insets.set(10, 10, 5, 10);
    c.gridx = 0; 
    c.gridy = 0;
    this.add(nameLabel, c);
    
    // Name field
    nameField = new JTextField();
    nameField.setPreferredSize(new Dimension(150, 20));
    nameField.setText("data.txt");
    nameField.addCaretListener(this);
    c.insets.set(0,10,10,10);       
    c.gridy++;
    this.add(nameField, c);
    
    // Folder to store the file
    folderNameCombo = new JComboBox(ImportUtils.getFolderNames(true).toArray());
    folderNameCombo.setPreferredSize(new Dimension(150, 20));
    folderNameCombo.setEditable(true);
    c.insets.set(10,10,5,10);
    c.gridy++;
    this.add(new JLabel("Create in folder"), c);
    c.insets.set(0,10,10,10);
    c.gridy++;
    this.add(folderNameCombo,c);
    
    // Text label
    textLabel = new JLabel("Text");
    c.anchor = GridBagConstraints.WEST;
    c.insets.set(10, 10, 5, 10);
    c.gridy++;
    this.add(textLabel, c);
    
    // Text area
    textArea = new JTextArea();
    textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
    textArea.setBorder(BorderFactory.createEmptyBorder());
    textArea.addCaretListener(this);
    JScrollPane areaScrollPane = new JScrollPane(textArea);
    areaScrollPane.setVerticalScrollBarPolicy(
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    areaScrollPane.setHorizontalScrollBarPolicy(
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    areaScrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    areaScrollPane.setPreferredSize(new Dimension(570, 300));
    c.insets.set(0,10,10,10);  
    c.gridy++;
    this.add(areaScrollPane, c);
    
    // OK button
    okButton = new JButton("OK");
    okButton.setPreferredSize(BUTTON_SIZE);
    okButton.addActionListener(this);
    
    // Cancel button
    cancelButton = new JButton("Cancel");
    cancelButton.setPreferredSize(BUTTON_SIZE);
    cancelButton.addActionListener(this);
    
    // Import checkbox
    importCheckBox = new JCheckBox("Import as plain text");
    importCheckBox.setSelected(true);
    c.insets.set(10, 10, 5, 10);
    c.gridy++;
    this.add(importCheckBox, c);
    
    // Buttons pannel
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets.set(10, 10, 5, 10);
    c.gridy++;
    this.add(buttonsPanel, c);
    
    // Show
    this.pack();
    this.setResizable(false);
    Session.getSession().getFrames().setLocationRelativeToMainFrame(this);
    
    // Default focus
    textArea.requestFocusInWindow();
    this.setVisible(true);
}
 
源代码16 项目: cropplanning   文件: PlanManager.java
@Override
protected void buildContentsPanel() {

  rdoBlank = new JRadioButton("a shiney, new, blank crop plan");
  rdoBlank.setSelected(true);
  rdoBasedOn = new JRadioButton("crop plan based on");
  rdoBlank.addItemListener(this);
  rdoBasedOn.addItemListener(this);
  ButtonGroup bg = new ButtonGroup();
  bg.add( rdoBlank );
  bg.add( rdoBasedOn );

  cmbPlans = new JComboBox( 
          oldPlans.toArray( new String[ oldPlans.size() ]) );
  cmbPlans.setEditable(false);
  cmbPlans.setEnabled(false);

  chkLockOld = new JCheckBox("Lock the old plan.");
  chkLockOld.setSelected(false);
  chkLockOld.setToolTipText("If selected, the old plan will be 'locked' so that " +
                            "it can't be editted, but can still be " +
                            "viewed and referenced and used to generate " +
                            "lists." );
  chkLockOld.setEnabled(false);



  JPanel jplCont = new JPanel( new MigLayout( "gapy 0px!, insets 2px", "[align right][]") );

  JLabel lblBasedOn = new JLabel( "<html><font size=\"-2\">" +
  "If you select the 'based on' option, all of your<br>" +
  "plantings will be copied from the selected plan<br>" +
  "into the new plan with these changes:" +
  "<ol> " +
  "<li>'Planned' dates will be adjusted<br>" +
          "to the selected year." +
  "<li>'Actual' dates (if any) will be blanked." +
  "<li>The 'Done ...' checkboxes will be<br>unselected." +
  "<li>They will all be given a keyword<br>" +
       "of 'from" + newPlan +"' so that you can<br>" +
       "search/filter for them as you<br>update them." +
  "</ol></font></html>");

  JLabel lblLock = new JLabel( "<html><font size=\"-2\">" +
  "If selected, the old plan will be 'locked' so that<br> " +
  "it can't be editted, but can still be viewed and<br>" +
  "used to generate lists and such." +
          "</font></html>" );

  int r = 1;
   jplCont.add( rdoBlank, "span 2, align left, wrap" );
   jplCont.add( rdoBasedOn, "align left" );
   jplCont.add( cmbPlans, "wrap" );
   jplCont.add( lblBasedOn, "span 2, wrap" );
   jplCont.add( chkLockOld, "span 2, align center, wrap" );
   jplCont.add( lblLock, "span 2, wrap" );

  
  jplCont.setBorder( BorderFactory.createEmptyBorder( 10, 10, 0, 10));

  contentsPanelBuilt = true;
  add( jplCont );

}
 
源代码17 项目: lsdpatch   文件: FontEditor.java
public FontEditor() {
      setTitle("Font Editor");
      setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
      setBounds(100, 100, 415, 324);
      setResizable(false);

      JMenuBar menuBar = new JMenuBar();
      setJMenuBar(menuBar);

      JMenu mnFile = new JMenu("File");
mnFile.setMnemonic(KeyEvent.VK_F);
      menuBar.add(mnFile);

      JMenuItem mntmOpen = new JMenuItem("Open...");
mntmOpen.setMnemonic(KeyEvent.VK_O);
      mntmOpen.addActionListener(this);
      mnFile.add(mntmOpen);

      JMenuItem mntmSave = new JMenuItem("Save...");
mntmSave.setMnemonic(KeyEvent.VK_S);
      mntmSave.addActionListener(this);
      mnFile.add(mntmSave);

      JMenu mnEdit = new JMenu("Edit");
mnEdit.setMnemonic(KeyEvent.VK_E);
      menuBar.add(mnEdit);

      JMenuItem mntmCopy = new JMenuItem("Copy Tile");
      mntmCopy.addActionListener(this);
      mntmCopy.setMnemonic(KeyEvent.VK_C);
      mnEdit.add(mntmCopy);

      JMenuItem mntmPaste = new JMenuItem("Paste Tile");
      mntmPaste.setMnemonic(KeyEvent.VK_P);
      mntmPaste.addActionListener(this);
      mnEdit.add(mntmPaste);

      contentPane = new JPanel();
      contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
      setContentPane(contentPane);
      contentPane.setLayout(null);

      fontMap = new FontMap();
      fontMap.setBounds(10, 42, 128, 146);
      fontMap.setTileSelectListener(this);
      contentPane.add(fontMap);

      tileEditor = new TileEditor();
      tileEditor.setBounds(148, 11, 240, 240);
      tileEditor.setTileChangedListener(this);
      contentPane.add(tileEditor);

      fontSelector = new JComboBox();
      fontSelector.setBounds(10, 11, 128, 20);
      fontSelector.setEditable(true);
      fontSelector.addItemListener(this);
      fontSelector.addActionListener(this);
      contentPane.add(fontSelector);

      color1 = new JRadioButton("1");
      color1.setBounds(10, 220, 37, 23);
      color1.addItemListener(this);
      color1.setMnemonic(KeyEvent.VK_1);
      contentPane.add(color1);

      color2 = new JRadioButton("2");
      color2.setBounds(49, 220, 37, 23);
      color2.addItemListener(this);
      color2.setMnemonic(KeyEvent.VK_2);
      contentPane.add(color2);

      color3 = new JRadioButton("3");
      color3.setBounds(88, 220, 37, 23);
      color3.addItemListener(this);
      color3.setSelected(true);
      color3.setMnemonic(KeyEvent.VK_3);
      contentPane.add(color3);

      colorGroup = new javax.swing.ButtonGroup();
      colorGroup.add(color1);
      colorGroup.add(color2);
      colorGroup.add(color3);

      JLabel lblColor = new JLabel("Color:");
      lblColor.setBounds(10, 199, 46, 14);
      contentPane.add(lblColor);
  }
 
源代码18 项目: chipster   文件: TaskImportDialog.java
public TaskImportDialog(ClientApplication application, String title, ImportSession importSession, Operation importOperation, String okButtonText, String cancelButtonText, String skipButtonText, String noteText) throws MicroarrayException {
	super(Session.getSession().getFrames().getMainFrame(), true);

	this.application = application;
	this.importSession = importSession;
	this.importOperation = importOperation;
	this.setTitle("Import");
	this.setModal(true);
	this.setPreferredSize(new Dimension(500, 300));

	// initialise components
	titleLabel = new JLabel("<html><p style=" + VisualConstants.HTML_DIALOG_TITLE_STYLE + ">" + title + "</p></html>");
	descriptionLabel = new JLabel("<html>" + importOperation.getDescription() + "</html>");
	noteLabel = new JLabel("<html><p style=\"font-style:italic\">" + noteText + "</p></html>");

	folderNameCombo = new JComboBox(ImportUtils.getFolderNames(false).toArray());
	folderNameCombo.setEditable(true);

	okButton = new JButton(okButtonText);
	okButton.setPreferredSize(BUTTON_SIZE);
	okButton.addActionListener(this);

	skipButton = new JButton(skipButtonText);
	skipButton.setPreferredSize(BUTTON_SIZE);
	skipButton.addActionListener(this);

	cancelButton = new JButton(cancelButtonText);
	cancelButton.setPreferredSize(BUTTON_SIZE);
	cancelButton.addActionListener(this);

	ImportParameterPanel parameterPanel = new ImportParameterPanel(importOperation, null);

	JPanel keepButtonsRightPanel = new JPanel(new GridBagLayout());
	GridBagConstraints buttonConstraints = new GridBagConstraints();
	buttonConstraints.weightx = 1.0;
	buttonConstraints.weighty = 1.0;
	buttonConstraints.anchor = GridBagConstraints.EAST;
	buttonConstraints.insets.set(0, 0, 0, 8);
	keepButtonsRightPanel.add(cancelButton, buttonConstraints);
	if (importSession != null) {
		buttonConstraints.anchor = GridBagConstraints.CENTER;		
		keepButtonsRightPanel.add(skipButton, buttonConstraints);
	}
	buttonConstraints.gridx = GridBagConstraints.RELATIVE;
	buttonConstraints.insets.set(0, 0, 0, 0);
	keepButtonsRightPanel.add(okButton, buttonConstraints);
	
	
	// layout
	GridBagConstraints c = new GridBagConstraints();
	this.setLayout(new GridBagLayout());

	// title label
	c.weightx = 1.0;
	c.weighty = 1.0;
	c.fill = GridBagConstraints.HORIZONTAL;
	c.anchor = GridBagConstraints.NORTHWEST;
	c.insets.set(10, 10, 5, 10);
	c.gridx = 0;
	c.gridy = 0;
	this.add(titleLabel, c);

	// description label
	c.gridy++;
	this.add(descriptionLabel, c);
	
	// parameter panel
	c.gridy++;
	c.weighty = 120.0;
	c.fill = GridBagConstraints.BOTH;
	c.anchor = GridBagConstraints.NORTHWEST;
	c.insets.set(0, 10, 10, 10);
	this.add(parameterPanel, c);

	// note
	c.gridy++;
	c.weightx = 1.0;
	c.weighty = 1.0;
	c.insets.set(0, 10, 10, 10);
	c.fill = GridBagConstraints.HORIZONTAL;
	this.add(noteLabel, c);
	
	// buttons
	c.insets.set(10, 10, 10, 10);
	c.anchor = GridBagConstraints.SOUTHEAST;
	c.gridy++;
	c.fill = GridBagConstraints.NONE;
	this.add(keepButtonsRightPanel, c);


	// make visible
	this.pack();
	Session.getSession().getFrames().setLocationRelativeToMainFrame(this);
	this.setVisible(true);
}
 
源代码19 项目: knopflerfish.org   文件: Desktop.java
void doConnect()
{
  final String[] options = new String[Activator.remoteHosts.size()];
  Activator.remoteHosts.copyInto(options);

  // The selection comp I want in the dialog
  final JComboBox combo = new JComboBox(options);
  combo.setEditable(true);

  // Mindboggling complicate way of creating an option dialog
  // without the auto-generated input field

  final JLabel msg = new JLabel(Strings.get("remote_connect_msg"));
  final JPanel panel = new JPanel(new BorderLayout());

  panel.add(combo, BorderLayout.SOUTH);
  panel.add(msg, BorderLayout.NORTH);

  final JOptionPane optionPane =
    new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE);
  optionPane.setIcon(connectIconLarge);
  optionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
  optionPane.setWantsInput(false);
  optionPane.setOptions(new String[] { Strings.get("ok"),
                                      Strings.get("cancel"),
                                      Strings.get("local"), });

  optionPane.selectInitialValue();

  final JDialog dialog =
    optionPane.createDialog(frame, Strings.get("remote_connect_title"));
  dialog.setVisible(true);
  dialog.dispose();

  if (!(optionPane.getValue() instanceof String)) { // We'll get an Integer if
                                                    // the user pressed Esc
    return;
  }

  final String value = (String) optionPane.getValue();

  if (Strings.get("cancel").equals(value)) {
    return;
  }

  String s = (String) combo.getSelectedItem();

  if (Strings.get("local").equals(value)) {
    s = "";
  }

  if (!Activator.remoteHosts.contains(s)) {
    Activator.remoteHosts.addElement(s);
  }

  if ((s != null)) {
    Activator.openRemote(s);
  }
}
 
源代码20 项目: nextreports-designer   文件: KeySelectionPanel.java
public KeySelectionPanel(boolean showValueField) {
    this.showValueField = showValueField;        
   
    keysCombo = new JComboBox();
    keysCombo.setEditable(true);
    AutoCompleteDecorator.decorate(keysCombo);
    keysCombo.setMinimumSize(dim);
    keysCombo.setPreferredSize(dim);
    if (showValueField) {
    	keysCombo.setEnabled(false);
    }
    
    List<String> keys = NextReportsUtil.getReportKeys();
    for (String key : keys) {
    	keysCombo.addItem(key);
    }        
    
    valueField = new JTextField();
    valueField.setMinimumSize(dim);
    valueField.setPreferredSize(dim);
    
    allCheck = new JCheckBox(I18NSupport.getString("languages.keys.selection.key.all"));

    setLayout(new GridBagLayout());
    
    add(new JLabel(I18NSupport.getString("languages.keys.selection.key")),
    		new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    add(keysCombo,
    		new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
    
    if (showValueField) {
    	add(new JLabel(I18NSupport.getString("languages.keys.selection.value")),
        		new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
                GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
        add(valueField,
        		new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
                GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 5), 0, 0));
    } else {
    	add(allCheck,
        		new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.WEST,
                GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
    }
}