List of usage examples for java.awt GridBagConstraints HORIZONTAL
int HORIZONTAL
To view the source code for java.awt GridBagConstraints HORIZONTAL.
Click Source Link
From source file:TextDemo.java
public TextDemo() { super(new GridBagLayout()); textField = new JTextField(20); textField.addActionListener(this); textArea = new JTextArea(5, 20); textArea.setEditable(false);/*w w w. j a va 2 s . co m*/ JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); //Add Components to this panel. GridBagConstraints c = new GridBagConstraints(); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; add(textField, c); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weighty = 1.0; add(scrollPane, c); }
From source file:biomine.bmvis2.pipeline.NodeLabelOperation.java
public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) { JPanel ret = new JPanel(); ret.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1;/* w w w .j a va 2 s .co m*/ c.weighty = 0; c.gridy = 0; final Set<String> avail = graph.getAvailableNodeLabels(); for (final String str : avail) { final JCheckBox box = new JCheckBox(); box.setSelected(enabledLabels.contains(str)); box.setAction(new AbstractAction(str) { public void actionPerformed(ActionEvent arg0) { if (box.isSelected() != enabledLabels.contains(str)) { if (box.isSelected()) enabledLabels.add(str); else enabledLabels.remove(str); v.settingsChanged(false); } } }); ret.add(box, c); c.gridy++; } return ret; }
From source file:be.ac.ua.comp.scarletnebula.gui.AllGraphsPanel.java
/** * Places all components (graphs) in the panel. *//*w w w.j a va2 s . c o m*/ private void placeComponents() { final GridBagConstraints constraints = new GridBagConstraints(); int numberOfComponentsPlaced = 0; int currXPos = 0; final int graphHeight = 150; final int graphWidth = 100; final Collection<String> datastreams = statisticsManager.getAvailableDatastreams(); for (final String streamname : datastreams) { LOG.info("drawing stream"); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 0.5; constraints.gridx = currXPos; constraints.gridy = numberOfComponentsPlaced / 2; constraints.insets = new Insets(10, 0, 0, 0); final DecoratedGraph graph = new DecoratedGraph((long) 10 * 60 * 1000, statisticsManager.getDatastream(streamname)); graph.registerRelativeDatastream(server, streamname, Color.GREEN); graph.addServerToRefresh(server); final ChartPanel chartPanel = graph.getChartPanel(); chartPanel.setPreferredSize(new Dimension(graphWidth, graphHeight)); add(chartPanel, constraints); if (currXPos == 0) { currXPos = 1; } else { currXPos = 0; } numberOfComponentsPlaced++; } }
From source file:com.digitalgeneralists.assurance.ui.components.FilePickerTextField.java
protected void initializeComponent() { if (!this.initialized) { this.filePicker.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); final JPanel filePathPanel = new JPanel(); filePathPanel.setLayout(new GridBagLayout()); GridBagConstraints filePathPanelConstraints = new GridBagConstraints(); filePathPanelConstraints.anchor = GridBagConstraints.NORTH; filePathPanelConstraints.fill = GridBagConstraints.HORIZONTAL; filePathPanelConstraints.gridx = 0; filePathPanelConstraints.gridy = 0; filePathPanelConstraints.weightx = 1.0; filePathPanelConstraints.weighty = 1.0; filePathPanelConstraints.gridheight = 1; filePathPanelConstraints.gridwidth = 2; filePathPanelConstraints.insets = new Insets(0, 0, 0, 0); GridBagConstraints pathTextFieldConstraints = new GridBagConstraints(); pathTextFieldConstraints.anchor = GridBagConstraints.NORTH; pathTextFieldConstraints.fill = GridBagConstraints.HORIZONTAL; pathTextFieldConstraints.gridx = 0; pathTextFieldConstraints.gridy = 0; pathTextFieldConstraints.weightx = 0.9; pathTextFieldConstraints.weighty = 1.0; pathTextFieldConstraints.gridheight = 1; pathTextFieldConstraints.gridwidth = 1; pathTextFieldConstraints.insets = new Insets(0, 0, 0, 0); GridBagConstraints pathFileChooserButtonConstraints = new GridBagConstraints(); pathFileChooserButtonConstraints.anchor = GridBagConstraints.NORTH; pathFileChooserButtonConstraints.fill = GridBagConstraints.HORIZONTAL; pathFileChooserButtonConstraints.gridx = 1; pathFileChooserButtonConstraints.gridy = 0; pathFileChooserButtonConstraints.weightx = 0.1; pathFileChooserButtonConstraints.weighty = 1.0; pathFileChooserButtonConstraints.gridheight = 1; pathFileChooserButtonConstraints.gridwidth = 1; pathFileChooserButtonConstraints.insets = new Insets(0, 0, 0, 0); filePathPanel.add(this.pathTextField, pathTextFieldConstraints); filePathPanel.add(this.pathFileChooserButton, pathFileChooserButtonConstraints); this.add(filePathPanel, filePathPanelConstraints); this.pathFileChooserButton.setActionCommand(AssuranceActions.chooseFilePathAction); this.pathTextField.getDocument().addDocumentListener(this.textPropertyValidationListener); this.pathFileChooserButton.addActionListener(this); this.initialized = true; }//from w ww .j a va2 s .co m }
From source file:coolmap.canvas.datarenderer.renderer.impl.NumberToBoxPlot.java
public NumberToBoxPlot() { setName("Number to BoxPlot"); setDescription("Use bar height to represent numeric values"); //initialize UI configUI.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0;//from ww w . j a v a2 s . c om c.gridy = 0; c.ipadx = 5; c.ipady = 5; c.insets = new Insets(5, 5, 5, 5); c.gridwidth = 1; c.gridx = 0; c.gridy++; c.gridwidth = 1; // JButton button = new JButton("Apply"); // configUI.add(button, c); // button.setToolTipText("Apply preset data ranges"); // button.addActionListener(new ActionListener() { // // @Override // public void actionPerformed(ActionEvent e) { // try { // MinMaxItem item = (MinMaxItem) (presetRangeComboBox.getSelectedItem()); // minValueField.setText(item.getMinMax().lowerEndpoint().toString()); // maxValueField.setText(item.getMinMax().upperEndpoint().toString()); // } catch (Exception ex) { // minValueField.setText("-1"); // maxValueField.setText("1"); // } // // updateRenderer(); // } // }); configUI.add(new JLabel("Preset range:"), c); c.gridx = 1; c.gridwidth = 1; presetRangeComboBox = new JComboBox(); configUI.add(presetRangeComboBox, c); presetRangeComboBox.addItem(new DataMinMaxItem()); presetRangeComboBox.addItem(new DefinedMinMaxItem(-1, 1)); presetRangeComboBox.addItem(new DefinedMinMaxItem(0, 1)); presetRangeComboBox.addItem(new DefinedMinMaxItem(-1, 0)); presetRangeComboBox.addItem(new DefinedMinMaxItem(0, 100)); presetRangeComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { try { MinMaxItem item = (MinMaxItem) (presetRangeComboBox.getSelectedItem()); minValueField.setText(item.getMinMax().lowerEndpoint().toString()); maxValueField.setText(item.getMinMax().upperEndpoint().toString()); } catch (Exception ex) { minValueField.setText("-1"); maxValueField.setText("1"); } } }); //////////////////////////////////////////////////////////////////////////////// // c.weightx = 0.2; c.gridx = 0; c.gridy++; c.gridwidth = 1; configUI.add(new JLabel("Min value: "), c); c.gridx = 1; // c.weightx = 0.3; configUI.add(minValueField, c); c.gridx = 0; c.gridy++; c.gridwidth = 1; configUI.add(new JLabel("Max value: "), c); c.gridx = 1; configUI.add(maxValueField, c); c.gridx = 0; c.gridy++; c.gridwidth = 1; configUI.add(new JLabel("Disect boundary: "), c); c.gridx = 1; configUI.add(disectField, c); disectField.setText("0"); c.gridx = 0; c.gridy++; c.gridwidth = 3; JButton button = new JButton("Update", UI.getImageIcon("refresh")); configUI.add(button, c); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //hit button, redraw! updateRenderer(); } }); }
From source file:fi.elfcloud.client.dialog.ModifyDataItemDialog.java
public ModifyDataItemDialog(JFrame parent, HashMap<String, String> metaMap, String diName) { super(parent, true); setTitle(Messages.getString("ModifyDataItemDialog.window_title") + diName); //$NON-NLS-1$ this.metamap = metaMap; tagVector = new Vector<String>(); setLocationRelativeTo(parent);// w ww.j a va2s . com panel.setLayout(new GridBagLayout()); GridBagConstraints cs = new GridBagConstraints(); cs.insets = new Insets(0, 0, 5, 0); lblName = new JLabel(Messages.getString("ModifyDataItemDialog.label_name")); //$NON-NLS-1$ cs.gridx = 0; cs.gridy = 0; cs.fill = GridBagConstraints.HORIZONTAL; cs.gridwidth = 1; cs.weightx = 0; panel.add(lblName, cs); name = new JTextField(getWidth()); cs.gridx = GridBagConstraints.RELATIVE; cs.gridy = 0; cs.fill = GridBagConstraints.HORIZONTAL; cs.gridwidth = 2; cs.weightx = 1.0; name.setText(diName); panel.add(name, cs); lblDescription = new JLabel(Messages.getString("ModifyDataItemDialog.label_description")); //$NON-NLS-1$ cs.gridx = 0; cs.gridy = 1; cs.gridwidth = 1; cs.fill = GridBagConstraints.HORIZONTAL; cs.weightx = 0; panel.add(lblDescription, cs); description = new JTextField(getWidth()); cs.gridx = GridBagConstraints.RELATIVE; cs.gridy = 1; cs.gridwidth = 2; cs.fill = GridBagConstraints.HORIZONTAL; cs.weightx = 1.0; description.setText(metaMap.get("DSC")); //$NON-NLS-1$ panel.add(description, cs); lblTags = new JLabel(Messages.getString("ModifyDataItemDialog.label_tags")); //$NON-NLS-1$ cs.gridx = 0; cs.gridy = 2; cs.gridwidth = 1; cs.fill = GridBagConstraints.HORIZONTAL; cs.weightx = 0; panel.add(lblTags, cs); tags = new JTextField(getWidth()); cs.gridx = GridBagConstraints.RELATIVE; cs.gridy = 2; cs.fill = GridBagConstraints.HORIZONTAL; cs.weightx = 1.0; panel.add(tags, cs); JButton addButton = new JButton(Messages.getString("ModifyDataItemDialog.button_add_tag")); //$NON-NLS-1$ cs.gridx = GridBagConstraints.RELATIVE; cs.gridy = 2; cs.gridwidth = 1; cs.weightx = 0; addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String tagText = tags.getText().trim(); if (!tagText.equals("")) { //$NON-NLS-1$ addTags(tagText); } tags.setText(""); //$NON-NLS-1$ checkboxPanel.revalidate(); checkboxPanel.repaint(); } }); panel.add(addButton, cs); checkboxPanel = new JPanel(new WrapLayout(FlowLayout.LEFT)); checkboxPanel.setSize(new Dimension(320, 1)); try { addTags(metamap.get("TGS")); //$NON-NLS-1$ } catch (NullPointerException e) { // No existing tags } panel.setBorder(new EmptyBorder(5, 5, 0, 5)); getContentPane().add(panel, BorderLayout.NORTH); scrollPane = new JScrollPane(checkboxPanel); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setBorder(null); getContentPane().add(scrollPane, BorderLayout.CENTER); JButton generateButton = new JButton(Messages.getString("ModifyDataItemDialog.button_save")); //$NON-NLS-1$ generateButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (tags.getText().length() > 0) { addTags(tags.getText()); } answer = true; setVisible(false); } }); JButton cancelButton = new JButton(Messages.getString("ModifyDataItemDialog.button_cancel")); //$NON-NLS-1$ cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { answer = false; setVisible(false); } }); JPanel bp = new JPanel(); bp.add(generateButton); bp.add(cancelButton); getContentPane().add(bp, BorderLayout.PAGE_END); setMinimumSize(new Dimension(320, 350)); pack(); }
From source file:org.executequery.gui.browser.SSHTunnelConnectionPanel.java
private void init() throws IOException { hostField = new DisabledField(); userNameField = WidgetFactory.createTextField(); passwordField = WidgetFactory.createPasswordField(); portField = WidgetFactory.createNumberTextField(); mainPanel = new TextFieldPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(10, 10, 10, 10); gbc.gridy = 0;/*from w w w .j av a 2 s.co m*/ gbc.gridx = 0; gbc.insets.bottom = 5; gbc.gridwidth = GridBagConstraints.REMAINDER; mainPanel.add(new DefaultFieldLabel( FileUtils.loadResource("org/executequery/gui/browser/resource/ssh-tunnel.html")), gbc); addLabelFieldPair(mainPanel, "SSH Host:", hostField, "The SSH host server for the tunnel", gbc); addLabelFieldPair(mainPanel, "SSH Port:", portField, "The SSH server port", gbc); addLabelFieldPair(mainPanel, "SSH User Name:", userNameField, "The SSH user name for the tunnel", gbc); addLabelFieldPair(mainPanel, "SSH Password:", passwordField, "The SSH user password for the tunnel", gbc); savePwdCheck = ActionUtilities.createCheckBox("Store Password", "setStorePassword"); JButton showPassword = new LinkButton("Show Password"); showPassword.setActionCommand("showPassword"); showPassword.addActionListener(this); JPanel passwordOptionsPanel = new JPanel(new GridBagLayout()); addComponents(passwordOptionsPanel, new ComponentToolTipPair[] { new ComponentToolTipPair(savePwdCheck, "Store the password with the connection information"), new ComponentToolTipPair(showPassword, "Show the password in plain text") }); gbc.gridy++; gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; mainPanel.add(passwordOptionsPanel, gbc); JScrollPane scrollPane = new JScrollPane(mainPanel); scrollPane.setBorder(null); useSshCheckbox = ActionUtilities.createCheckBox(this, "Connect Using an SSH Tunnel", "useSshSelected"); ComponentTitledPanel titledPanel = new ComponentTitledPanel(useSshCheckbox); JPanel panel = titledPanel.getContentPane(); panel.setLayout(new BorderLayout()); panel.add(scrollPane, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(titledPanel, BorderLayout.NORTH); }
From source file:width.java
public void init() { GridBagLayout gridBag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridBag);//from ww w. j a va2s. co m Label receiverLabel = new Label("Receiver name:", Label.RIGHT); gridBag.setConstraints(receiverLabel, c); add(receiverLabel); nameField = new TextField(getParameter("RECEIVERNAME"), 10); c.fill = GridBagConstraints.HORIZONTAL; gridBag.setConstraints(nameField, c); add(nameField); nameField.addActionListener(this); Button button = new Button("Send message"); c.gridwidth = GridBagConstraints.REMAINDER; //end row c.anchor = GridBagConstraints.WEST; //stick to the //text field c.fill = GridBagConstraints.NONE; //keep the button //small gridBag.setConstraints(button, c); add(button); button.addActionListener(this); status = new TextArea(5, 60); status.setEditable(false); c.anchor = GridBagConstraints.CENTER; //reset to the default c.fill = GridBagConstraints.BOTH; //make this big c.weightx = 1.0; c.weighty = 1.0; gridBag.setConstraints(status, c); add(status); myName = getParameter("NAME"); Label senderLabel = new Label("(My name is " + myName + ".)", Label.CENTER); c.weightx = 0.0; c.weighty = 0.0; gridBag.setConstraints(senderLabel, c); add(senderLabel); newline = System.getProperty("line.separator"); }
From source file:ProgressDialog.java
private void setupComponent() { JPanel contentPane = (JPanel) getContentPane(); contentPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new GridBagLayout()); GridBagConstraints gc = new GridBagConstraints(); gc.gridx = 0;//from w w w.j a v a 2 s . c o m gc.gridy = GridBagConstraints.RELATIVE; gc.anchor = GridBagConstraints.NORTHWEST; contentPane.add(lblMessage, gc); gc.weightx = 1; gc.fill = GridBagConstraints.HORIZONTAL; contentPane.add(progressBar, gc); setTitle(""); setModal(true); pack(); }
From source file:de.tor.tribes.ui.components.DatePicker.java
private void init() { //build Header for (int i = 0; i < 7; i++) { JLabel head = new JLabel(dayNames[i]); head.setBackground(GRAY);/* w w w . ja v a 2 s. c o m*/ head.setOpaque(true); head.setPreferredSize(new Dimension(20, 20)); head.setMinimumSize(new Dimension(20, 20)); head.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.PAGE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = i; gbc.gridy = 0; gbc.insets = new Insets(2, 2, 6, 2); gbc.ipadx = 0; gbc.ipady = 0; gbc.weightx = 1.0; gbc.weighty = 0.0; jPanelDaySelection.add(head, gbc); } daysInMonth = new CrossedLabel[WEEKS_TO_SHOW][7]; datesInMonth = new Date[WEEKS_TO_SHOW][7]; for (int i = 0; i < WEEKS_TO_SHOW; i++) { for (int j = 0; j < 7; j++) { daysInMonth[i][j] = new CrossedLabel(); daysInMonth[i][j].setPreferredSize(new Dimension(20, 20)); daysInMonth[i][j].setMinimumSize(new Dimension(20, 20)); daysInMonth[i][j].setHorizontalAlignment(javax.swing.SwingConstants.CENTER); daysInMonth[i][j].addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseevent) { dayClicked(mouseevent); } }); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.PAGE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = j; gbc.gridy = i + 1; gbc.insets = new Insets(2, 2, 2, 2); gbc.ipadx = 0; gbc.ipady = 0; gbc.weightx = 1.0; gbc.weighty = 0.0; jPanelDaySelection.add(daysInMonth[i][j], gbc); } } buildCalendar(); }