Java Code Examples for javax.swing.JComboBox#setPreferredSize()
The following examples show how to use
javax.swing.JComboBox#setPreferredSize() .
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: JComboBoxOverlapping.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
protected void prepareControls() { frame = new JFrame("Mixing : Dropdown Overlapping test"); frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS)); frame.setSize(200, 200); frame.setVisible(true); cb = new JComboBox(petStrings); cb.setPreferredSize(new Dimension(frame.getContentPane().getWidth(), 20)); cb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() == cb) { lwClicked = true; } } }); frame.add(cb); propagateAWTControls(frame); frame.setVisible(true); }
Example 2
Source File: CSettingsPanelBuilder.java From binnavi with Apache License 2.0 | 6 votes |
/** * Adds a combobox for a setting with multiple options. * * @param panel The panel the combobox is added to. * @param comboBox The combobox to add. * @param description The text of the label to be put next to the combobox. * @param hint Tooltip shown when the user mouse-overs the created hint icon. * @param values The options to be put into the combobox. * @param selectedOption The index of the option to select by default. */ public static void addComboBox(final JPanel panel, final JComboBox<String> comboBox, final String description, final String hint, final String[] values, final int selectedOption) { Preconditions.checkNotNull(panel, "IE01595: Panel argument can not be null"); Preconditions.checkNotNull(comboBox, "IE01596: Combo box argument can not be null"); Preconditions.checkNotNull(description, "IE01597: Description argument can not be null"); Preconditions.checkNotNull(values, "IE01598: Values argument can not be null"); for (final String string : values) { comboBox.addItem(string); } comboBox.setSelectedIndex(selectedOption); comboBox.setPreferredSize(new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT)); addComponent(panel, comboBox, description, hint); }
Example 3
Source File: LanguageSelectionPanel.java From nextreports-designer with Apache License 2.0 | 6 votes |
public LanguageSelectionPanel() { languagesCombo = new JComboBox(); languagesCombo.setMinimumSize(dim); languagesCombo.setPreferredSize(dim); for (Country c : LocaleUtil.getCountries()) { languagesCombo.addItem(c); } languagesCombo.setSelectedItem(LocaleUtil.getCountry(Globals.getConfigLocale())); languagesCombo.setRenderer(new CountryRenderer()); defaultCheck = new JCheckBox(I18NSupport.getString("languages.default")); setLayout(new GridBagLayout()); add(new JLabel(I18NSupport.getString("languages.selection")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(languagesCombo, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); add(defaultCheck, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); }
Example 4
Source File: RemoteExecutionDialog.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
private static JComboBox<String> buildProductFormatNamesComboBox(Insets defaultListItemMargins, int textFieldPreferredHeight, String[] availableFormatNames) { JComboBox<String> productFormatNameComboBox = new JComboBox<String>(availableFormatNames); Dimension formatNameComboBoxSize = productFormatNameComboBox.getPreferredSize(); formatNameComboBoxSize.height = textFieldPreferredHeight; productFormatNameComboBox.setPreferredSize(formatNameComboBoxSize); productFormatNameComboBox.setMinimumSize(formatNameComboBoxSize); LabelListCellRenderer<String> renderer = new LabelListCellRenderer<String>(defaultListItemMargins) { @Override protected String getItemDisplayText(String value) { return value; } }; productFormatNameComboBox.setMaximumRowCount(5); productFormatNameComboBox.setRenderer(renderer); productFormatNameComboBox.setBackground(new Color(0, 0, 0, 0)); // set the transparent color productFormatNameComboBox.setOpaque(true); return productFormatNameComboBox; }
Example 5
Source File: TextBoxPanel.java From energy2d with GNU Lesser General Public License v3.0 | 6 votes |
private static JComboBox<String> createFontNameComboBox() { JComboBox<String> c = new JComboBox<String>(FONT_FAMILY_NAMES); c.setRenderer(new ComboBoxRenderer.FontLabel()); c.setToolTipText("Font type"); FontMetrics fm = c.getFontMetrics(c.getFont()); int max = 0, n = 0; for (int i = 0; i < FONT_FAMILY_NAMES.length; i++) { n = fm.stringWidth(FONT_FAMILY_NAMES[i]); if (max < n) max = n; } int w = max + 50; int h = fm.getHeight() + 8; c.setPreferredSize(new Dimension(w, h)); c.setEditable(false); c.setRequestFocusEnabled(false); return c; }
Example 6
Source File: TextBoxPanel.java From energy2d with GNU Lesser General Public License v3.0 | 5 votes |
private static JComboBox<Integer> createFontSizeComboBox() { JComboBox<Integer> c = new JComboBox<Integer>(FONT_SIZE); c.setToolTipText("Font size"); FontMetrics fm = c.getFontMetrics(c.getFont()); int w = fm.stringWidth(FONT_SIZE[FONT_SIZE.length - 1].toString()) + 40; int h = fm.getHeight() + 8; c.setPreferredSize(new Dimension(w, h)); c.setEditable(false); c.setRequestFocusEnabled(false); return c; }
Example 7
Source File: VargaChartPanel.java From Astrosoft with GNU General Public License v2.0 | 5 votes |
public VargaChartPanel(PlanetaryInfo planetaryInfo, Dimension panelSize) { this.planetaryInfo = planetaryInfo; this.panelSize = panelSize; vargaCombo = new JComboBox(Varga.values()); vargaCombo.setFont(UIUtil.getFont("Tahoma", Font.PLAIN, 11)); vargaCombo.setSelectedItem(Varga.Rasi); vargaCombo.setPreferredSize(comboSize); vargaCombo.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { vargaChanged((Varga)vargaCombo.getSelectedItem()); } }); setLayout(new BorderLayout()); //chartSize = panelSize; //chartSize = new Dimension((int)(panelSize.width * 0.95), (int) (panelSize.height * 0.95)); vargaChanged(Varga.Rasi); JPanel p = new JPanel(); p.add(vargaCombo); add(p,BorderLayout.PAGE_START); add(new JPanel(),BorderLayout.PAGE_END); //setPreferredSize(panelSize); }
Example 8
Source File: PipeApplicationBuilder.java From PIPE with MIT License | 5 votes |
/** * 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); }
Example 9
Source File: DataSourceWizardPanel.java From nextreports-designer with Apache License 2.0 | 5 votes |
private void init() { setLayout(new BorderLayout()); dataSourceCombo = new JComboBox(); dataSourceCombo.setPreferredSize(dim); dataSourceCombo.setRenderer(new DataSourceRenderer()); populateDataSources(null); addDataSourceButton = new JButton(); addDataSourceButton.setPreferredSize(buttonDim); addDataSourceButton.setMaximumSize(buttonDim); addDataSourceButton.setMinimumSize(buttonDim); JPanel dsPanel = new JPanel(new GridBagLayout()); dsPanel.add(new JLabel(I18NSupport.getString("wizard.panel.datasource.label")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); dsPanel.add(dataSourceCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); dsPanel.add(addDataSourceButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); dsPanel.add(new JLabel(""), new GridBagConstraints(3, 0, 1, 2, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); add(dsPanel, BorderLayout.CENTER); }
Example 10
Source File: BioItem.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
protected void setComboBoxModel(CharacterComboBoxModel<?> model) { combobox.ifPresent(box -> { throw new IllegalStateException( "The CharacterComboBoxModel has already been set"); //$NON-NLS-1$ }); JComboBox<?> newComboBox = new JComboBox<>(model); this.combobox = Optional.of(newComboBox); newComboBox.setPreferredSize(new Dimension(10, BiographyInfoPane.TEMPLATE_TEXT_FIELD.getPreferredSize().height)); }
Example 11
Source File: JPlagCreator.java From jplag with GNU General Public License v3.0 | 5 votes |
public static JComboBox<String> createJComboBox(String[] items, int width, int height, String toolTip) { JComboBox<String> comboBox = new JComboBox<String>(items); comboBox.setPreferredSize(new java.awt.Dimension(width, height)); comboBox.setBackground(java.awt.Color.white); comboBox.setFont(JPlagCreator.SYSTEM_FONT); if (toolTip != null) comboBox.setToolTipText(toolTip); return comboBox; }
Example 12
Source File: BioItem.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
protected void setComboBoxModel(CharacterComboBoxModel<?> model) { combobox.ifPresent(box -> { throw new IllegalStateException( "The CharacterComboBoxModel has already been set"); //$NON-NLS-1$ }); JComboBox<?> newComboBox = new JComboBox<>(model); this.combobox = Optional.of(newComboBox); newComboBox.setPreferredSize(new Dimension(10, BiographyInfoPane.TEMPLATE_TEXT_FIELD.getPreferredSize().height)); }
Example 13
Source File: CSettingsPanelBuilder.java From binnavi with Apache License 2.0 | 5 votes |
/** * Adds a combobox for a setting that can be switched on or off. * * @param panel The panel the combobox is added to. * @param comboBox The combobox to add. * @param description The text of the label to be put next to the combobox. * @param hint Tooltip shown when the user mouse-overs the created hint icon. * @param value True to set the combobox value to ON, false to set it to OFF. */ public static void addComboBox(final JPanel panel, final JComboBox<String> comboBox, final String description, final String hint, final boolean value) { Preconditions.checkNotNull(panel, "IE01592: Panel argument can not be null"); Preconditions.checkNotNull(comboBox, "IE01593: Combo box argument can not be null"); Preconditions.checkNotNull(description, "IE01594: Description argument can not be null"); comboBox.addItem("On"); comboBox.addItem("Off"); comboBox.setSelectedItem(value ? "On" : "Off"); comboBox.setPreferredSize(new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT)); addComponent(panel, comboBox, description, hint); }
Example 14
Source File: ConnectionAction.java From netbeans with Apache License 2.0 | 4 votes |
private void initComponents() { setLayout(new BorderLayout(4, 0)); setBorder(new EmptyBorder(0, 2, 0, 8)); setOpaque(false); setFocusTraversalPolicyProvider(true); setFocusTraversalPolicy(new DefaultFocusTraversalPolicy() { @Override public Component getDefaultComponent(Container aContainer) { if (!SwingUtilities.isEventDispatchThread()) { return null; } final EditorCookie ec = actionContext.lookup( EditorCookie.class); if (ec != null) { JEditorPane[] panes = ec.getOpenedPanes(); if (panes != null) { for (JEditorPane pane : panes) { if (pane.isShowing()) { return pane; } } } } return null; } }); combo = new JComboBox(); combo.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { DatabaseConnection dbconn = (DatabaseConnection)combo.getSelectedItem(); combo.setToolTipText(dbconn != null ? dbconn.getDisplayName() : null); } }); combo.setOpaque(false); combo.setModel(new DefaultComboBoxModel( new String[] { NbBundle.getMessage(ToolbarPresenter.class, "ConnectionAction.ToolbarPresenter.LoadingConnections") })); combo.setRenderer(new DatabaseConnectionRenderer()); String accessibleName = NbBundle.getMessage(ConnectionAction.class, "LBL_DatabaseConnection"); combo.getAccessibleContext().setAccessibleName(accessibleName); combo.getAccessibleContext().setAccessibleDescription(accessibleName); combo.setPreferredSize (new Dimension (400, combo.getPreferredSize ().height)); add(combo, BorderLayout.CENTER); comboLabel = new JLabel(); Mnemonics.setLocalizedText(comboLabel, NbBundle.getMessage(ConnectionAction.class, "LBL_ConnectionAction")); comboLabel.setOpaque(false); comboLabel.setLabelFor(combo); add(comboLabel, BorderLayout.WEST); }
Example 15
Source File: ShapefileAssistantPage3.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
@Override public Component createPageComponent() { mapPanel = new JPanel(new BorderLayout()); mapLabel = new JLabel(); mapLabel.setHorizontalAlignment(JLabel.CENTER); mapPanel.add(mapLabel, BorderLayout.CENTER); LayerSourcePageContext context = getContext(); String filePath = (String) context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FILE_PATH); String fileName = new File(filePath).getName(); infoLabel = new JLabel(); styleList = new JComboBox(); styleList.setRenderer(new StyleListCellRenderer()); styleList.addItemListener(new StyleSelectionListener()); styleList.setPreferredSize(new Dimension(100, styleList.getPreferredSize().height)); JPanel panel2 = new JPanel(new BorderLayout(4, 4)); panel2.setBorder(new EmptyBorder(4, 4, 4, 4)); panel2.add(new JLabel("Style:"), BorderLayout.WEST); panel2.add(styleList, BorderLayout.EAST); JPanel panel3 = new JPanel(new BorderLayout(4, 4)); panel3.setBorder(new EmptyBorder(4, 4, 4, 4)); panel3.add(new JLabel(String.format("<html><b>%s</b>", fileName)), BorderLayout.CENTER); panel3.add(panel2, BorderLayout.EAST); JPanel panel = new JPanel(new BorderLayout(4, 4)); panel.setBorder(new EmptyBorder(4, 4, 4, 4)); panel.add(panel3, BorderLayout.NORTH); panel.add(mapPanel, BorderLayout.CENTER); panel.add(infoLabel, BorderLayout.SOUTH); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { updateMap(); } }); return panel; }
Example 16
Source File: KeySelectionPanel.java From nextreports-designer with Apache License 2.0 | 4 votes |
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)); } }
Example 17
Source File: ToadDataPanel.java From mvisc with GNU General Public License v3.0 | 4 votes |
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 18
Source File: URLImportDialog.java From chipster with MIT License | 4 votes |
public URLImportDialog(SwingClientApplication client) { super(client.getMainFrame(), true); if(recentURLs == null){ recentURLs = new LinkedList<String>(); } this.client = client; this.setTitle("Import data from URL"); this.setModal(true); label = new JLabel("Insert URL"); label.setFont(label.getFont().deriveFont(Font.BOLD)); label.setPreferredSize(LABEL_SIZE); folderNameCombo = new JComboBox(ImportUtils.getFolderNames(true).toArray()); folderNameCombo.setEditable(true); skipCheckBox = new JCheckBox(VisualConstants.getImportDirectlyText()); if (!Session.getSession().getApplication().isStandalone()) { skipCheckBox.setSelected(true); } else { skipCheckBox.setSelected(false); } okButton = new JButton("OK"); okButton.setPreferredSize(BUTTON_SIZE); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.setPreferredSize(BUTTON_SIZE); cancelButton.addActionListener(this); String[] comboValues = new String[recentURLs.size() + 1]; comboValues[0] = "http://"; for(int i = 0; i < recentURLs.size(); i++){ comboValues[i+1] = recentURLs.get(i); } URLComboBox = new JComboBox(comboValues); URLComboBox.setBackground(Color.WHITE); URLComboBox.setPreferredSize(COMBO_SIZE); URLComboBox.setEditable(true); GridBagConstraints c = new GridBagConstraints(); this.setLayout(new GridBagLayout()); // Label c.anchor = GridBagConstraints.WEST; c.insets.set(10, 10, 5, 10); c.gridx = 0; c.gridy = 0; this.add(label, c); // Combobox c.insets.set(0,10,10,10); c.gridy++; this.add(URLComboBox, c); c.insets.set(10,10,5,10); c.gridy++; this.add(new JLabel("Insert in folder"),c); c.fill = GridBagConstraints.HORIZONTAL; c.insets.set(0,10,10,10); c.gridy++; this.add(folderNameCombo,c); c.insets.set(10, 10, 10, 10); c.anchor = GridBagConstraints.EAST; c.gridy++; this.add(skipCheckBox,c); c.fill = GridBagConstraints.HORIZONTAL; c.gridy++; JPanel keepButtonsRightPanel = new JPanel(); keepButtonsRightPanel.add(okButton); keepButtonsRightPanel.add(cancelButton); this.add(keepButtonsRightPanel, c); this.pack(); this.setLocationRelativeTo(null); URLComboBox.requestFocusInWindow(); this.setVisible(true); }
Example 19
Source File: CreateFromTextDialog.java From chipster with MIT License | 4 votes |
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); }