List of usage examples for java.awt GridBagConstraints REMAINDER
int REMAINDER
To view the source code for java.awt GridBagConstraints REMAINDER.
Click Source Link
From source file:org.n52.ifgicopter.spf.gui.FrameworkCorePanel.java
/** * default constructor to create the framework core panel. */// w w w .j av a 2 s .c om public FrameworkCorePanel() { /* * INPUT PLUGIN LIST */ this.pluginsPanel = new JPanel(); this.pluginsPanel.setLayout(new GridBagLayout()); this.pluginsPanel.setBackground(DEFAULT_COLOR); this.globalGBC = new GridBagConstraints(); this.globalGBC.gridx = 0; this.globalGBC.gridy = 0; this.globalGBC.weightx = 0.0; this.globalGBC.weighty = 0.0; this.globalGBC.anchor = GridBagConstraints.NORTHWEST; this.globalGBC.fill = GridBagConstraints.HORIZONTAL; this.pluginsPanel.add( new JLabel("<html><body><div><strong>" + "Active Plugins</strong></div></body></html>"), this.globalGBC); this.globalGBC.gridy++; this.globalGBC.gridwidth = GridBagConstraints.REMAINDER; this.globalGBC.insets = new Insets(0, 0, 5, 0); this.pluginsPanel.add(new JSeparator(), this.globalGBC); this.globalGBC.insets = new Insets(0, 0, 0, 0); this.globalGBC.weightx = 1.0; this.globalGBC.gridy = 0; this.globalGBC.gridx = 1; this.pluginsPanel.add(Box.createHorizontalGlue(), this.globalGBC); this.globalGBC.weightx = 0.0; this.globalGBC.gridx = 0; this.globalGBC.gridy = 1; /* * the contentpanel */ this.contentPanel = new JPanel(); this.contentPanel.setLayout(new CardLayout()); this.contentPanel.setBorder(BorderFactory.createEtchedBorder()); this.contentPanel.add(WelcomePanel.getInstance(), WELCOME_PANEL); // ((CardLayout) contentPanel.getLayout()).show(contentPanel, WELCOME_PANEL); JScrollPane startupS = new JScrollPane(this.contentPanel); startupS.setViewportBorder(null); /* * wrap the plugins to ensure top alignment */ JPanel pluginsPanelWrapper = new JPanel(new BorderLayout()); pluginsPanelWrapper.add(this.pluginsPanel, BorderLayout.NORTH); pluginsPanelWrapper.add(Box.createVerticalGlue(), BorderLayout.CENTER); pluginsPanelWrapper.setBorder(BorderFactory.createEtchedBorder()); pluginsPanelWrapper.setBackground(this.pluginsPanel.getBackground()); JScrollPane wrapperS = new JScrollPane(pluginsPanelWrapper); wrapperS.setViewportBorder(null); /* * add both scroll panes to the split pane */ JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, wrapperS, startupS); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); splitPane.setContinuousLayout(true); Dimension minimumSize = new Dimension(100, 100); startupS.setMinimumSize(minimumSize); this.setLayout(new BorderLayout()); this.add(splitPane); }
From source file:com.att.aro.ui.view.menu.datacollector.DeviceDialogOptions.java
private void setUpLayoutProperties() { contentLayout = new GridBagLayout(); labelConstraints = new GridBagConstraints(); labelConstraints.fill = GridBagConstraints.BOTH; labelConstraints.weightx = 0.3;/* w ww . jav a 2 s . c om*/ labelConstraints.gridwidth = GridBagConstraints.RELATIVE; optionConstraints = new GridBagConstraints(); optionConstraints.fill = GridBagConstraints.BOTH; optionConstraints.weightx = 1.0; optionConstraints.gridwidth = GridBagConstraints.REMAINDER; }
From source file:savant.view.dialog.LoadGenomeDialog.java
/** This method is called from within the constructor to * initialize the form./* w w w . j a v a 2 s .c o m*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; withoutSequenceButtonGroup = new javax.swing.ButtonGroup(); javax.swing.JLabel fromLabel = new javax.swing.JLabel(); fromFileButton = new javax.swing.JButton(); fromURLButton = new javax.swing.JButton(); fromOtherButton = new javax.swing.JButton(); javax.swing.JSeparator jSeparator1 = new javax.swing.JSeparator(); publishedGenomeRadio = new javax.swing.JRadioButton(); javax.swing.JLabel speciesLabel = new javax.swing.JLabel(); genomesCombo = new javax.swing.JComboBox(); auxiliaryPanel = new javax.swing.JPanel(); javax.swing.JSeparator jSeparator2 = new javax.swing.JSeparator(); userSpecifiedRadio = new javax.swing.JRadioButton(); javax.swing.JLabel nameLabel = new javax.swing.JLabel(); nameField = new javax.swing.JTextField(); javax.swing.JLabel lengthLabel = new javax.swing.JLabel(); lengthField = new javax.swing.JTextField(); javax.swing.JSeparator jSeparator3 = new javax.swing.JSeparator(); okButton = new javax.swing.JButton(); javax.swing.JButton cancelButton = new javax.swing.JButton(); withoutSequenceButtonGroup.add(publishedGenomeRadio); withoutSequenceButtonGroup.add(userSpecifiedRadio); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Load Genome"); getContentPane().setLayout(new java.awt.GridBagLayout()); fromLabel.setText("Load from:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(30, 30, 3, 3); getContentPane().add(fromLabel, gridBagConstraints); fromFileButton.setText("File"); fromFileButton.setPreferredSize(new java.awt.Dimension(150, 29)); fromFileButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { fromFileButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); getContentPane().add(fromFileButton, gridBagConstraints); fromURLButton.setText("URL"); fromURLButton.setPreferredSize(new java.awt.Dimension(150, 29)); fromURLButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { fromURLButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); getContentPane().add(fromURLButton, gridBagConstraints); fromOtherButton.setText("Other Datasource"); fromOtherButton.setPreferredSize(new java.awt.Dimension(150, 29)); fromOtherButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { fromOtherButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); getContentPane().add(fromOtherButton, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 9; gridBagConstraints.ipady = 9; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(3, 15, 3, 15); getContentPane().add(jSeparator1, gridBagConstraints); publishedGenomeRadio.setSelected(true); publishedGenomeRadio.setText("Published Genome"); publishedGenomeRadio.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { publishedGenomeRadioActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(3, 30, 3, 3); getContentPane().add(publishedGenomeRadio, gridBagConstraints); speciesLabel.setText("Genome:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(3, 30, 3, 3); getContentPane().add(speciesLabel, gridBagConstraints); genomesCombo.setToolTipText("Species of a published genome to load"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 30); getContentPane().add(genomesCombo, gridBagConstraints); auxiliaryPanel.setLayout(new java.awt.GridBagLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 5; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 30; gridBagConstraints.ipady = 30; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 30); getContentPane().add(auxiliaryPanel, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 9; gridBagConstraints.ipady = 9; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(3, 15, 3, 15); getContentPane().add(jSeparator2, gridBagConstraints); userSpecifiedRadio.setText("User-specified"); userSpecifiedRadio.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { userSpecifiedRadioActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 7; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(3, 30, 3, 3); getContentPane().add(userSpecifiedRadio, gridBagConstraints); nameLabel.setText("Name:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 8; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; getContentPane().add(nameLabel, gridBagConstraints); nameField.setToolTipText("Name of reference (must correspond to name in records)"); nameField.setEnabled(false); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 8; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 90); getContentPane().add(nameField, gridBagConstraints); lengthLabel.setText("Length:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 9; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; getContentPane().add(lengthLabel, gridBagConstraints); lengthField.setToolTipText("Length in basepairs of reference"); lengthField.setEnabled(false); lengthField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { lengthFieldFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 9; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 150); getContentPane().add(lengthField, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 10; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 9; gridBagConstraints.ipady = 9; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(3, 15, 3, 15); getContentPane().add(jSeparator3, gridBagConstraints); okButton.setText("OK"); okButton.setPreferredSize(new java.awt.Dimension(90, 29)); okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { okButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 5; gridBagConstraints.gridy = 11; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(3, 3, 30, 30); getContentPane().add(okButton, gridBagConstraints); cancelButton.setText("Cancel"); cancelButton.setPreferredSize(new java.awt.Dimension(90, 29)); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 11; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST; gridBagConstraints.weightx = 0.5; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(3, 3, 30, 3); getContentPane().add(cancelButton, gridBagConstraints); pack(); }
From source file:TextSamplerDemo.java
public TextSamplerDemo() { setLayout(new BorderLayout()); //Create a regular text field. JTextField textField = new JTextField(10); textField.setActionCommand(textFieldString); textField.addActionListener(this); //Create a password field. JPasswordField passwordField = new JPasswordField(10); passwordField.setActionCommand(passwordFieldString); passwordField.addActionListener(this); //Create a formatted text field. JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime()); ftf.setActionCommand(textFieldString); ftf.addActionListener(this); //Create some labels for the fields. JLabel textFieldLabel = new JLabel(textFieldString + ": "); textFieldLabel.setLabelFor(textField); JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": "); passwordFieldLabel.setLabelFor(passwordField); JLabel ftfLabel = new JLabel(ftfString + ": "); ftfLabel.setLabelFor(ftf);/*w w w . ja v a 2 s .c om*/ //Create a label to put messages during an action event. actionLabel = new JLabel("Type text and then Enter in a field."); actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); //Lay out the text controls and the labels. JPanel textControlsPane = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); textControlsPane.setLayout(gridbag); JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel }; JTextField[] textFields = { textField, passwordField, ftf }; addLabelTextRows(labels, textFields, gridbag, textControlsPane); c.gridwidth = GridBagConstraints.REMAINDER; //last c.anchor = GridBagConstraints.WEST; c.weightx = 1.0; textControlsPane.add(actionLabel, c); textControlsPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Create a text area. JTextArea textArea = new JTextArea("This is an editable JTextArea. " + "A text area is a \"plain\" text component, " + "which means that although it can display text " + "in any font, all of the text is in the same font."); textArea.setFont(new Font("Serif", Font.ITALIC, 16)); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(250, 250)); areaScrollPane.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), areaScrollPane.getBorder())); //Create an editor pane. JEditorPane editorPane = createEditorPane(); JScrollPane editorScrollPane = new JScrollPane(editorPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); editorScrollPane.setPreferredSize(new Dimension(250, 145)); editorScrollPane.setMinimumSize(new Dimension(10, 10)); //Create a text pane. JTextPane textPane = createTextPane(); JScrollPane paneScrollPane = new JScrollPane(textPane); paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); paneScrollPane.setPreferredSize(new Dimension(250, 155)); paneScrollPane.setMinimumSize(new Dimension(10, 10)); //Put the editor pane and the text pane in a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setResizeWeight(0.5); JPanel rightPane = new JPanel(new GridLayout(1, 0)); rightPane.add(splitPane); rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Put everything together. JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(textControlsPane, BorderLayout.PAGE_START); leftPane.add(areaScrollPane, BorderLayout.CENTER); add(leftPane, BorderLayout.LINE_START); add(rightPane, BorderLayout.LINE_END); }
From source file:org.pentaho.ui.xul.swing.SwingElement.java
public void layout() { super.layout(); double totalFlex = 0.0; if (isVisible() == false) { resetContainer();/*from ww w .j a v a 2 s. c o m*/ return; } for (Element comp : getChildNodes()) { // if (comp.getManagedObject() == null) { // continue; // } if (((XulComponent) comp).getFlex() > 0) { flexLayout = true; totalFlex += ((XulComponent) comp).getFlex(); } } double currentFlexTotal = 0.0; Align alignment = (getAlign() != null) ? Align.valueOf(this.getAlign().toUpperCase()) : null; for (int i = 0; i < getChildNodes().size(); i++) { XulComponent comp = (XulComponent) getChildNodes().get(i); gc.fill = GridBagConstraints.BOTH; if (comp instanceof XulSplitter) { JPanel prevContainer = container; container = new ScrollablePanel(new GridBagLayout()); container.setOpaque(false); final JSplitPane splitter = new JSplitPane( (this.getOrientation() == Orient.VERTICAL) ? JSplitPane.VERTICAL_SPLIT : JSplitPane.HORIZONTAL_SPLIT, prevContainer, container); splitter.setContinuousLayout(true); final double splitterSize = currentFlexTotal / totalFlex; splitter.setResizeWeight(splitterSize); if (totalFlex > 0) { splitter.addComponentListener(new ComponentListener() { public void componentHidden(ComponentEvent arg0) { } public void componentMoved(ComponentEvent arg0) { } public void componentShown(ComponentEvent arg0) { } public void componentResized(ComponentEvent arg0) { splitter.setDividerLocation(splitterSize); splitter.removeComponentListener(this); } }); } if (!flexLayout) { if (this.getOrientation() == Orient.VERTICAL) { // VBox and such gc.weighty = 1.0; } else { gc.weightx = 1.0; } prevContainer.add(Box.createGlue(), gc); } setManagedObject(splitter); } Object maybeComponent = comp.getManagedObject(); if (maybeComponent == null || !(maybeComponent instanceof Component)) { continue; } if (this.getOrientation() == Orient.VERTICAL) { // VBox and such gc.gridheight = comp.getFlex() + 1; gc.gridwidth = GridBagConstraints.REMAINDER; gc.weighty = (totalFlex == 0) ? 0 : (comp.getFlex() / totalFlex); } else { gc.gridwidth = comp.getFlex() + 1; gc.gridheight = GridBagConstraints.REMAINDER; gc.weightx = (totalFlex == 0) ? 0 : (comp.getFlex() / totalFlex); } currentFlexTotal += comp.getFlex(); if (this.getOrientation() == Orient.VERTICAL) { // VBox and such if (alignment != null) { gc.fill = GridBagConstraints.NONE; switch (alignment) { case START: gc.anchor = GridBagConstraints.WEST; break; case CENTER: gc.anchor = GridBagConstraints.CENTER; break; case END: gc.anchor = GridBagConstraints.EAST; break; } } } else { if (alignment != null) { gc.fill = GridBagConstraints.NONE; switch (alignment) { case START: gc.anchor = GridBagConstraints.NORTH; break; case CENTER: gc.anchor = GridBagConstraints.CENTER; break; case END: gc.anchor = GridBagConstraints.SOUTH; break; } } } Component component = (Component) maybeComponent; if (comp.getWidth() > 0 || comp.getHeight() > 0) { Dimension minSize = component.getMinimumSize(); Dimension prefSize = component.getPreferredSize(); if (comp.getWidth() > 0) { minSize.width = comp.getWidth(); prefSize.width = comp.getWidth(); } if (comp.getHeight() > 0) { minSize.height = comp.getHeight(); prefSize.height = comp.getHeight(); } component.setMinimumSize(minSize); component.setPreferredSize(prefSize); } container.add(component, gc); if (i + 1 == getChildNodes().size() && !flexLayout) { if (this.getOrientation() == Orient.VERTICAL) { // VBox and such gc.weighty = 1.0; } else { gc.weightx = 1.0; } container.add(Box.createGlue(), gc); } } }
From source file:pcgen.gui.sources.SourceSelectionDialog.java
/** * This method is called from within the constructor to * initialize the form./*from w w w . ja va 2s . c o m*/ */ private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(new java.awt.GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); JLabel jLabel1 = new JLabel(LanguageBundle.getString("in_qsrc_intro")); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0.0, 0.0); getContentPane().add(jLabel1, gbc); sourceList = new javax.swing.JList(); sourceModel = new DefaultListModel(); List<String> strings = getSourceNames(); for (String string : strings) { sourceModel.addElement(string); } sourceList.setModel(sourceModel); sourceList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); sourceList.setLayoutOrientation(JList.VERTICAL_WRAP); sourceList.setVisibleRowCount(2); sourceList.setCellRenderer(new SourceListCellRenderer()); JScrollPane listScrollPane = new JScrollPane(sourceList); listScrollPane.setPreferredSize(new Dimension(480, 260)); if (lastLoadedCollection != null && lastLoadedCollection.length() > 0) { sourceList.setSelectedValue(lastLoadedCollection, true); } Utility.buildRelativeConstraints(gbc, 2, 5, 100, 100, GridBagConstraints.BOTH, GridBagConstraints.WEST); getContentPane().add(listScrollPane, gbc); JButton addButton = new JButton(LanguageBundle.getString("in_add")); addButton.setActionCommand(ACTION_ADD); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); getContentPane().add(addButton, gbc); modifyButton = new JButton(LanguageBundle.getString("in_modify")); modifyButton.setActionCommand(ACTION_MODIFY); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); getContentPane().add(modifyButton, gbc); JButton hideButton = new JButton(LanguageBundle.getString("in_hide")); hideButton.setActionCommand(ACTION_HIDE); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); getContentPane().add(hideButton, gbc); JButton unhideButton = new JButton(LanguageBundle.getString("in_unhide")); unhideButton.setActionCommand(ACTION_UNHIDE); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); getContentPane().add(unhideButton, gbc); deleteButton = new JButton(LanguageBundle.getString("in_delete")); deleteButton.setActionCommand(ACTION_DELETE); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); getContentPane().add(deleteButton, gbc); JButton advancedButton = new JButton(LanguageBundle.getString("in_qsrc_advanced")); advancedButton.setActionCommand(ACTION_ADVANCED); getRootPane().setDefaultButton(advancedButton); Utility.buildRelativeConstraints(gbc, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST); getContentPane().add(advancedButton, gbc); JButton loadButton = new JButton(LanguageBundle.getString("in_load")); loadButton.setActionCommand(ACTION_LOAD); getRootPane().setDefaultButton(loadButton); Utility.buildRelativeConstraints(gbc, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.EAST); getContentPane().add(loadButton, gbc); JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel")); cancelButton.setActionCommand(ACTION_CANCEL); Utility.buildRelativeConstraints(gbc, 1, 1, 0, 0); getContentPane().add(cancelButton, gbc); //Listen for actions on the buttons addButton.addActionListener(this); modifyButton.addActionListener(this); deleteButton.addActionListener(this); hideButton.addActionListener(this); unhideButton.addActionListener(this); advancedButton.addActionListener(this); loadButton.addActionListener(this); cancelButton.addActionListener(this); sourceList.addListSelectionListener(this); valueChanged(null); //Listen for actions on the list sourceList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { sourceListMouseClicked(evt); } }); pack(); }
From source file:org.executequery.gui.ExecuteSqlScriptPanel.java
private void init() throws Exception { fileNameField = WidgetFactory.createTextField(); connectionsCombo = WidgetFactory.createComboBox(); combosGroup = new TableSelectionCombosGroup(connectionsCombo); actionOnErrorCombo = WidgetFactory.createComboBox(); ActionOnError[] actionsOnError = { ActionOnError.HALT, ActionOnError.CONTINUE }; actionOnErrorCombo.setModel(new DefaultComboBoxModel(actionsOnError)); outputPanel = new LoggingOutputPanel(); statusBar = new SqlTextPaneStatusBar(); statusBar.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 1)); JButton button = WidgetFactory.createInlineFieldButton("Browse"); button.setActionCommand("browse"); button.addActionListener(this); button.setMnemonic('r'); logOutputCheckBox = new JCheckBox( "<html> <i>Note:</i> This will slow down the process significantly </html>"); JPanel mainPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 0;/*from w w w . ja v a2s.c o m*/ gbc.gridx = 0; gbc.gridheight = 1; gbc.insets.top = 7; gbc.insets.bottom = 5; gbc.insets.right = 5; gbc.insets.left = 5; gbc.anchor = GridBagConstraints.NORTHWEST; mainPanel.add(new JLabel("Connection:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.insets.top = 5; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(connectionsCombo, gbc); gbc.gridy++; gbc.gridx = 0; gbc.weightx = 0; gbc.gridwidth = 1; gbc.insets.top = 5; mainPanel.add(new JLabel("Action on Error:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets.top = 0; mainPanel.add(actionOnErrorCombo, gbc); gbc.gridy++; gbc.gridx = 0; gbc.weightx = 0; gbc.gridwidth = 1; gbc.insets.top = 5; mainPanel.add(new JLabel("Input File:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.insets.top = 0; mainPanel.add(fileNameField, gbc); gbc.gridx = 2; gbc.weightx = 0; gbc.insets.left = 0; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(button, gbc); gbc.gridy++; gbc.gridx = 0; gbc.insets.top = 5; gbc.insets.left = 5; mainPanel.add(new JLabel("Log output:"), gbc); gbc.gridx = 1; gbc.insets.top = 2; gbc.insets.left = 0; mainPanel.add(logOutputCheckBox, gbc); gbc.gridy++; gbc.gridx = 0; gbc.weighty = 1.0; gbc.weightx = 1.0; gbc.insets.top = 5; gbc.insets.left = 5; gbc.insets.bottom = 0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; mainPanel.add(outputPanel, gbc); gbc.gridy++; gbc.gridx = 0; gbc.weighty = 0; gbc.insets.bottom = 5; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(statusBar, gbc); mainPanel.setBorder(BorderFactory.createEtchedBorder()); int minimumButtonWidth = 85; startButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Start", "start"); rollbackButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Commit", "commit"); commitButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Rollback", "rollback"); stopButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Stop", "stop"); rollbackButton.setEnabled(false); commitButton.setEnabled(false); stopButton.setEnabled(false); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 5)); buttonPanel.add(startButton); buttonPanel.add(rollbackButton); buttonPanel.add(commitButton); buttonPanel.add(stopButton); add(mainPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); EventMediator.registerListener(this); }
From source file:com.frostwire.gui.bittorrent.PartialFilesDialog.java
private void setupCancelButton() { GridBagConstraints c;/*from ww w. ja v a2 s . c o m*/ _buttonCancel = new JButton(I18n.tr("Cancel")); _buttonCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { buttonCancel_actionPerformed(e); } }); c = new GridBagConstraints(); c.insets = new Insets(4, 0, 8, 6); c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.EAST; c.ipadx = 18; c.gridy = 4; panel.add(_buttonCancel, c); }
From source file:org.ut.biolab.medsavant.client.view.component.SelectableListView.java
protected final void initContentPanel() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); if (availableValues == null) { JTextArea label = new JTextArea("There are too many values to display."); label.setOpaque(false);/*from www . j a va2s . c om*/ label.setLineWrap(true); label.setWrapStyleWord(true); gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(3, 3, 3, 3); add(label, gbc); return; } AbstractListModel model = new SelectableListView.SimpleListModel(); field = new QuickListFilterField(model); field.setHintText("Type here to filter options"); // the width of the field has to be less than the width // provided to the filter, otherwise, it will push the grid wider // and components will be inaccessible field.setPreferredSize(new Dimension(FIELD_WIDTH, 22)); filterableList = new FilterableCheckBoxList(field.getDisplayListModel()) { @Override public int getNextMatch(String prefix, int startIndex, Position.Bias bias) { return -1; } @Override public boolean isCheckBoxEnabled(int index) { return true; } }; filterableList.getCheckBoxListSelectionModel() .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); if (model.getSize() > 0) { filterableList.setPrototypeCellValue(model.getElementAt(0)); // Makes it much faster to determine the view's preferred size. } SearchableUtils.installSearchable(filterableList); setAllSelected(true); JScrollPane jsp = new JScrollPane(filterableList) { @Override public Dimension getPreferredSize() { Dimension result = super.getPreferredSize(); result = new Dimension(Math.min(result.width, SelectableListView.this.getWidth() - 20), result.height); return result; } }; selectAll = ViewUtil.createHyperLinkButton("Select All"); selectAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setAllSelected(true); } }); JButton selectNone = ViewUtil.createHyperLinkButton("Select None"); selectNone.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setAllSelected(false); } }); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(3, 15, 3, 15); add(field, gbc); gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(3, 3, 3, 3); add(jsp, gbc); gbc.gridwidth = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.fill = GridBagConstraints.HORIZONTAL; JPanel bottom = new JPanel(); ViewUtil.applyHorizontalBoxLayout(bottom); bottom.add(selectAll); bottom.add(selectNone); bottom.add(Box.createHorizontalGlue()); JButton applyButton = new JButton("Apply"); applyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { saveSelections(); } }); bottom.add(applyButton); add(bottom, gbc); }
From source file:org.openconcerto.erp.core.sales.shipment.component.BonDeLivraisonSQLComponent.java
public void addViews() { this.textTotalHT.setOpaque(false); this.textTotalTVA.setOpaque(false); this.textTotalTTC.setOpaque(false); this.selectCommande = new ElementComboBox(); this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); // Champ Module c.gridx = 0;//from w w w . j av a 2 s.co m c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; final JPanel addP = ComptaSQLConfElement.createAdditionalPanel(); this.setAdditionalFieldsPanel(new FormLayouter(addP, 2)); this.add(addP, c); c.gridy++; c.gridwidth = 1; // Numero JLabel labelNum = new JLabel(getLabelFor("NUMERO")); labelNum.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelNum, c); this.textNumeroUnique = new JUniqueTextField(16); c.gridx++; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.NONE; DefaultGridBagConstraints.lockMinimumSize(textNumeroUnique); this.add(this.textNumeroUnique, c); // Date c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; this.add(new JLabel(getLabelFor("DATE"), SwingConstants.RIGHT), c); JDate date = new JDate(true); c.gridx++; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.add(date, c); // Reference c.gridy++; c.gridx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; this.add(this.textNom, c); if (getTable().contains("DATE_LIVRAISON")) { // Date livraison c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; this.add(new JLabel(getLabelFor("DATE_LIVRAISON"), SwingConstants.RIGHT), c); JDate dateLivraison = new JDate(true); c.gridx++; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.add(dateLivraison, c); this.addView(dateLivraison, "DATE_LIVRAISON"); } // Client JLabel labelClient = new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT); c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; c.weighty = 0; this.add(labelClient, c); c.gridx++; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; this.comboClient = new ElementComboBox(); this.add(this.comboClient, c); if (getTable().contains("SPEC_LIVRAISON")) { // Date livraison c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; this.add(new JLabel(getLabelFor("SPEC_LIVRAISON"), SwingConstants.RIGHT), c); JTextField specLivraison = new JTextField(); c.gridx++; c.weightx = 0; c.weighty = 0; this.add(specLivraison, c); this.addView(specLivraison, "SPEC_LIVRAISON"); } final ElementComboBox boxTarif = new ElementComboBox(); this.comboClient.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (comboClient.getElement().getTable().contains("ID_TARIF")) { if (BonDeLivraisonSQLComponent.this.isFilling()) return; final SQLRow row = ((SQLRequestComboBox) evt.getSource()).getSelectedRow(); if (row != null) { // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF"); // if (foreignRow.isUndefined() && // !row.getForeignRow("ID_DEVISE").isUndefined()) { // SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable()); // rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE")); // foreignRow = rowValsD; // // } // tableBonItem.setTarif(foreignRow, true); SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF"); if (!foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID()) && JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associs au client?") == JOptionPane.YES_OPTION) { boxTarif.setValue(foreignRow.getID()); // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow, // true); } else { boxTarif.setValue(foreignRow.getID()); } } } } }); // Bouton tout livrer JButton boutonAll = new JButton("Tout livrer"); boutonAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RowValuesTableModel m = BonDeLivraisonSQLComponent.this.tableBonItem.getModel(); // on livre tout les lments for (int i = 0; i < m.getRowCount(); i++) { SQLRowValues rowVals = m.getRowValuesAt(i); Object o = rowVals.getObject("QTE"); int qte = o == null ? 0 : ((Number) o).intValue(); m.putValue(qte, i, "QTE_LIVREE"); } } }); // Tarif if (this.getTable().getFieldsName().contains("ID_TARIF")) { // TARIF c.gridy++; c.gridx = 0; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; this.add(new JLabel("Tarif appliquer"), c); c.gridx++; c.gridwidth = 1; c.weightx = 1; this.add(boxTarif, c); this.addView(boxTarif, "ID_TARIF"); boxTarif.addModelListener("wantedID", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID()); tableBonItem.setTarif(selectedRow, !isFilling()); } }); } if (getTable().contains("A_ATTENTION")) { // Date livraison c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; this.add(new JLabel(getLabelFor("A_ATTENTION"), SwingConstants.RIGHT), c); JTextField specLivraison = new JTextField(); c.gridx++; c.weightx = 0; c.weighty = 0; this.add(specLivraison, c); this.addView(specLivraison, "A_ATTENTION"); } // Element du bon List<JButton> l = new ArrayList<JButton>(); l.add(boutonAll); this.tableBonItem = new BonDeLivraisonItemTable(l); c.gridx = 0; c.gridy++; c.weightx = 1; c.weighty = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; this.add(this.tableBonItem, c); c.anchor = GridBagConstraints.EAST; // Totaux reconfigure(this.textTotalHT); reconfigure(this.textTotalTVA); reconfigure(this.textTotalTTC); // Poids Total c.gridy++; c.gridx = 1; c.weightx = 0; c.weighty = 0; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; this.addSQLObject(this.textPoidsTotal, "TOTAL_POIDS"); this.addRequiredSQLObject(this.textTotalHT, "TOTAL_HT"); this.addRequiredSQLObject(this.textTotalTVA, "TOTAL_TVA"); this.addRequiredSQLObject(this.textTotalTTC, "TOTAL_TTC"); TotalPanel panelTotal = new TotalPanel(tableBonItem, textTotalHT, textTotalTVA, textTotalTTC, new DeviseField(), new DeviseField(), new DeviseField(), new DeviseField(), new DeviseField(), textPoidsTotal, null); c.gridx = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0; c.weighty = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; this.add(panelTotal, c); c.anchor = GridBagConstraints.WEST; /******************************************************************************************* * * INFORMATIONS COMPLEMENTAIRES ******************************************************************************************/ c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy++; TitledSeparator sep = new TitledSeparator("Informations complmentaires"); c.insets = new Insets(10, 2, 1, 2); this.add(sep, c); c.insets = new Insets(2, 2, 1, 2); ITextArea textInfos = new ITextArea(4, 4); c.gridx = 0; c.gridy++; c.gridheight = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.BOTH; final JScrollPane scrollPane = new JScrollPane(textInfos); this.add(scrollPane, c); textInfos.setBorder(null); DefaultGridBagConstraints.lockMinimumSize(scrollPane); c.gridx = 0; c.gridy++; c.gridheight = 1; c.gridwidth = 4; c.weightx = 0; c.weighty = 0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; this.panelOO = new PanelOOSQLComponent(this); this.add(this.panelOO, c); this.addRequiredSQLObject(date, "DATE"); this.addSQLObject(textInfos, "INFOS"); this.addSQLObject(this.textNom, "NOM"); this.addSQLObject(this.selectCommande, "ID_COMMANDE_CLIENT"); this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO"); this.addRequiredSQLObject(this.comboClient, "ID_CLIENT"); // Doit etre lock a la fin DefaultGridBagConstraints.lockMinimumSize(comboClient); }