private void createLayout() { mViewDocButton.setHorizontalAlignment(SwingConstants.LEFT); mViewDocButton.setEnabled(false); mLinksScrollPane.getViewport().add(mLinksList); setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.CENTER; constraints.insets = GUIConstants.INSETS; constraints.gridwidth = 1; constraints.gridheight = 2; constraints.gridx = 0; constraints.gridy = 0; constraints.weightx = 1; constraints.weighty = 1; constraints.fill = GridBagConstraints.BOTH; add(mLinksScrollPane, constraints); constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridheight = 1; constraints.gridx = 1; add(mViewDocButton, constraints); }
protected JPanel buildVersionLockingFieldChooser() { GridBagConstraints constraints = new GridBagConstraints(); Pane lockingPanel = new Pane(new GridBagLayout()); JLabel lockingFieldLabel = buildLabel("EIS_LOCKING_POLICY_XPATH"); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.LINE_START; constraints.insets = new Insets(0, 0, 0, 0); lockingPanel.add(lockingFieldLabel, constraints); XpathChooser xpathChooser = new XpathChooser(this.getWorkbenchContextHolder(), buildLockingFieldSelectionHolder()); xpathChooser.setAccessibleLabeler(lockingFieldLabel); constraints.gridx = 1; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(0, 5, 0, 0); lockingPanel.add(xpathChooser, constraints); return lockingPanel; }
public Plot2Da() { check_ = new JCheckBox("Hold on"); plot_ = new Plot2D(); setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 2, 2); c.weightx = 1.0; c.weighty = 1.0; c.gridheight = 1; c.gridwidth = 1; c.gridx = 0; c.gridy = 0; add(check_, c); c.gridwidth = 1; c.gridheight = 1; c.gridx = 0; c.gridy = 1; c.fill = GridBagConstraints.REMAINDER; c.ipadx = plot_.getSize().width + 100; c.ipady = plot_.getSize().height + 100; plot_.setBackground(Color.WHITE); add(plot_, c); setBorder(BorderFactory.createEtchedBorder()); }
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; nameLabel = new javax.swing.JLabel(); nameTextField = new javax.swing.JTextField(); setLayout(new java.awt.GridBagLayout()); setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 12, 12)); nameLabel.setLabelFor(nameTextField); nameLabel.setText("Folders:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 6); add(nameLabel, gridBagConstraints); nameTextField.setColumns(25); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(nameTextField, gridBagConstraints); }
/** Init the panel contents */ private void init() { setLayout(new GridBagLayout()); JButton changeDirButton = ((ChangeCWDAction) table.getActionMap().get("cwd")).createButton(); JButton upDirButton = ((ChangeCWDAction) table.getActionMap().get("cwd")).createParentDirButton(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0; gbc.fill = GridBagConstraints.VERTICAL; gbc.anchor = GridBagConstraints.LINE_START; add(changeDirButton, gbc); gbc.gridx = 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = 1; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.LINE_START; add(table.getComboBox(), gbc); gbc.gridx = 2; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = 0; gbc.fill = GridBagConstraints.VERTICAL; gbc.anchor = GridBagConstraints.LINE_START; add(upDirButton, gbc); }
@Override protected void initializeLayout() { GridBagConstraints constraints = new GridBagConstraints(); // Field pairs table JComponent tablePanel = this.buildFieldPairsTablePanel(); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(0, 0, 0, 0); this.add(tablePanel, constraints); // Button panel JPanel buttonPanel = this.buildButtonPanel(); constraints.gridx = 1; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.PAGE_START; constraints.insets = new Insets(0, 5, 0, 0); this.add(buttonPanel, constraints); }
public void load() { luser = new JXLabel(i18n.Language.getLabel(model.getEntity().getModelEntity().getIdLng()) + ":"); tuser = new JList(); tuser.setEnabled(false); checklistmanager = new CheckListManager(tuser); checklistmanager .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!checklistmanager.getSelectionModel().isSelectionEmpty()) { ArrayList<String> a = new ArrayList<>(); for (int i = checklistmanager.getSelectionModel().getMinSelectionIndex(); i <= checklistmanager.getSelectionModel().getMaxSelectionIndex(); i++) { if (checklistmanager.getSelectionModel().isSelectedIndex(i)) { a.add(model.getListUser().get(i)); } } model.setListUserSelect(a); } } }); suser = new JScrollPane(tuser); pButton.addButton(pButton.bSelect, "selectAll"); pButton.addButton(pButton.bUnselect, "unselectAll"); pButton.bSelect.addActionListener(this); pButton.bUnselect.addActionListener(this); gbc = new GridBagConstraints(); int y = 0; gbc.gridx = 0; gbc.gridy = y; gbc.gridwidth = 1; gbc.weightx = 0.1; gbc.anchor = java.awt.GridBagConstraints.WEST; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new java.awt.Insets(spaceTop + 10, spaceLeft + 10, spaceBottom, spaceRight); this.add(luser, gbc); gbc.gridx = 1; gbc.gridy = y; gbc.gridheight = 2; gbc.weightx = 0.9; gbc.insets = new java.awt.Insets(spaceTop + 10, spaceLeft, spaceBottom, spaceRight); this.add(suser, gbc); y += 2; gbc.gridx = 1; gbc.gridy = y; gbc.gridheight = 1; gbc.weightx = 1; gbc.insets = new java.awt.Insets(spaceTop, spaceLeft, spaceBottom, spaceRight); this.add(pButton, gbc); }
private void createCellType_2() { gbConstraints.gridx = 0; gbConstraints.gridy = 1; gbConstraints.gridwidth = 1; gbConstraints.gridheight = 1; gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.weightx = 1; gbConstraints.weighty = 0; gbConstraints.anchor = GridBagConstraints.NORTH; gbConstraints.insets = new Insets(1, 1, 1, 1); gbLayout.setConstraints((JTextField) al.get(0), gbConstraints); add((JTextField) al.get(0)); gbConstraints.gridx = 0; gbConstraints.gridy = 2; gbConstraints.gridwidth = 1; gbConstraints.gridheight = 1; gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.weightx = 1; gbConstraints.weighty = 0; gbConstraints.anchor = GridBagConstraints.NORTH; gbConstraints.insets = new Insets(1, 1, 1, 1); gbLayout.setConstraints((JTextField) al.get(1), gbConstraints); add((JTextField) al.get(1)); }
protected void initializeLayout() { GridBagConstraints constraints = new GridBagConstraints(); setBorder( BorderFactory.createTitledBorder( resourceRepository().getString("FIELD_ACCESSING_PANEL_BORDER_TEXT"))); JRadioButton methodAccessingRadioButton = buildMethodAccessingRadioButton(); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.LINE_START; constraints.insets = new Insets(0, 5, 0, 5); add(methodAccessingRadioButton, constraints); JRadioButton fieldAccessingRadioButton = buildFieldAccessingRadioButton(); constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.FIRST_LINE_START; constraints.insets = new Insets(0, 5, 0, 5); add(fieldAccessingRadioButton, constraints); }
protected void initializeLayout() { this.sortedFieldsAdapter = this.buildSortedInsertFieldReturnOnlyFlagsAdapter(); this.tableModel = this.buildTableModel(); this.rowSelectionModel = this.buildRowSelectionModel(); GridBagConstraints constraints = new GridBagConstraints(); // Create the button panel first JPanel buttonPanel = buildButtonPanel(); constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.LINE_END; constraints.insets = new Insets(5, 0, 0, 0); add(buttonPanel, constraints); // Create the table after since some listeners need access to the buttons JComponent insertTablePane = buildInsertPanel(); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.FIRST_LINE_START; constraints.insets = new Insets(0, 0, 0, 0); add(insertTablePane, constraints); }
protected void initializeLayout() { this.setBorder( BorderFactory.createCompoundBorder( this.buildTitledBorder("FOREIGN_KEYS_TITLE"), BorderFactory.createEmptyBorder(0, 5, 5, 5))); int offset = SwingTools.checkBoxIconWidth(); GridBagConstraints constraints = new GridBagConstraints(); PropertyValueModel foreignKeyLocationHolder = buildForeignKeyLocationHolderValue(); // Foreign keys on target button JRadioButton foreignKeysOnTargetButton = this.buildForeignKeysOnTargetButton(foreignKeyLocationHolder); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.LINE_START; constraints.insets = new Insets(0, 0, 0, 0); this.add(foreignKeysOnTargetButton, constraints); addHelpTopicId(foreignKeysOnTargetButton, "mapping.eisOneToMany.foreignKeyOnTarget"); // Foreign keys on source button JRadioButton foreignKeysOnSourceButton = this.buildForeignKeysOnSourceButton(foreignKeyLocationHolder); constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.LINE_START; constraints.insets = new Insets(0, 0, 0, 0); this.add(foreignKeysOnSourceButton, constraints); addHelpTopicId(foreignKeysOnSourceButton, "mapping.eisOneToMany.foreginKeyOnSource"); // Field pairs subpanel AbstractPanel fieldPairsSubPane = new FieldPairsSubPane(); constraints.gridx = 0; constraints.gridy = 2; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(0, offset, 0, 0); this.add(fieldPairsSubPane, constraints); this.addPaneForAlignment(fieldPairsSubPane); new ComponentEnabler(foreignKeyLocationHolder, fieldPairsSubPane); addHelpTopicId(this, "mapping.eisOneToMany.foreignKeys"); }
public MA_ScrollPane( Vector period_types, int scrollbarDisplayPolicy, Chart parent_chart, Properties print_props) { super(scrollbarDisplayPolicy); if (print_props != null) print_properties = print_props; MA_Configuration config = MA_Configuration.application_instance(); chart = parent_chart; main_graph = new MainGraph(); indicator_graph = new LowerGraph(main_graph); GridBagLayout gblayout = new GridBagLayout(); GridBagConstraints gbconstraints = new GridBagConstraints(); main_panel = new Panel(new BorderLayout()); add(main_panel, "Center"); graph_panel = new Panel(gblayout); main_panel.add(graph_panel, "Center"); // Set GridBagLayout constraints such that the main graph is at // the top and takes about 2/3 of available height and the // indicator graph is below the main graph and takes the remaining // 1/3 of the height and both graph panels grow/shrink when the // window is resized. gbconstraints.gridx = 0; gbconstraints.gridy = 0; gbconstraints.gridwidth = 9; gbconstraints.gridheight = 6; gbconstraints.weightx = 1; gbconstraints.weighty = 1; gbconstraints.fill = GridBagConstraints.BOTH; gblayout.setConstraints(main_graph, gbconstraints); graph_panel.add(main_graph); gbconstraints.gridx = 0; gbconstraints.gridy = 6; gbconstraints.gridwidth = 9; gbconstraints.gridheight = 3; gbconstraints.weightx = 1; gbconstraints.weighty = 1; gbconstraints.fill = GridBagConstraints.BOTH; gblayout.setConstraints(indicator_graph, gbconstraints); graph_panel.add(indicator_graph); main_graph.set_framecolor(new Color(0, 0, 0)); main_graph.set_borderTop(0); main_graph.set_borderBottom(1); main_graph.set_borderLeft(0); main_graph.set_borderRight(1); main_graph.setGraphBackground(config.background_color()); main_graph.setSize(400, 310); indicator_graph.set_framecolor(new Color(0, 0, 0)); indicator_graph.set_borderTop(0); indicator_graph.set_borderBottom(1); indicator_graph.set_borderLeft(0); indicator_graph.set_borderRight(1); indicator_graph.setGraphBackground(config.background_color()); indicator_graph.setSize(400, 150); }
/** * Initializes the layout of this <code>GroupBox</code>. * * @param buttons The buttons to be shown at the top-left section of the group box * @param panes The panes to be shown as a group where a button is shown as a pane's title */ protected void initializeLayout(AbstractButton[] buttons, JComponent[] panes) { checkIntegrity(buttons, panes); GridBagConstraints constraints = new GridBagConstraints(); for (int index = 0; index < buttons.length; index++) { boolean paneWasAddedBefore = ((index > 0) && (panes[index - 1] != NO_PANE)); // First add the button AbstractButton button = buttons[index]; button.setOpaque(false); // Requires to paint the titled border properly button.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(0, 5, 0, 0), button.getBorder())); if (panes[index] != NO_PANE) { button.addItemListener(buildRepainterHandler()); } constraints.gridx = 0; constraints.gridy = index; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.FIRST_LINE_START; constraints.insets = new Insets(paneWasAddedBefore ? 5 : 0, 0, 0, 0); add(button, constraints); // Now add the pane if one is associated with the button JComponent pane = panes[index]; if (pane != NO_PANE) { boolean fillVertical = shouldFillVertical(pane); int top = button.getPreferredSize().height / 2 - 6; pane.setBorder( BorderFactory.createCompoundBorder(createPaneBorder(button, pane), pane.getBorder())); constraints.gridx = 0; constraints.gridy = index; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = fillVertical ? 1 : 0; constraints.fill = fillVertical ? GridBagConstraints.BOTH : GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(paneWasAddedBefore ? top + 5 : top, 0, 0, 0); add(pane, constraints); } } }
/** * An array or varargs of components with prompts to put in a 2 column grid. The rows are defined * by the length of the arrays and it is assumed the array lengths are equal. * * @param title The title border text. * @param rowWeight This "row" in the column will receive all "extra" space. * @param prompts Text used as a prompt to the components. * @param components The components to lay out nicely. */ public PromptPanel(String title, int rowWeight, String[] prompts, JComponent[] components) { setLayout(new GridBagLayout()); if (title != null) { setBorder(BorderFactory.createTitledBorder(title)); } else { setBorder(BorderFactory.createEmptyBorder()); } double weight = 0.0; if (rowWeight == -1) { weight = ((double) components.length) / 2.0; } GridBagConstraints gbc = null; for (int i = 0; i < components.length; i++) { gbc = new GridBagConstraints(); // First do do the prompt. gbc.weightx = 0.0; if (rowWeight == i) { gbc.weighty = 1.0; } else { gbc.weighty = weight; } gbc.gridx = 0; gbc.gridy = i; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.anchor = GridBagConstraints.EAST; gbc.insets = new Insets(INSET, INSET, INSET, INSET); add(new JLabel(prompts[i]), gbc); // Now the component. gbc = new GridBagConstraints(); gbc.weightx = 1.0; if (rowWeight == i) { gbc.weighty = 1.0; } else { gbc.weighty = weight; } gbc.gridx = 1; gbc.gridy = i; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(INSET, INSET, INSET, INSET); add(components[i], gbc); } }
/** * Used to create the top panel describing the current feedback question * * @param fb Feedback question to describe * @return Panel with title and description */ public JPanel createQuestionDataPanel(AbstractFeedbackType fb) { JPanel questionPanel = new JPanel(); questionPanel.setLayout(new GridBagLayout()); questionPanel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); GridBagConstraints leftBoxConst = new GridBagConstraints(); leftBoxConst.anchor = GridBagConstraints.LINE_START; leftBoxConst.gridx = 0; leftBoxConst.gridy = 0; leftBoxConst.gridheight = 2; JLabel titleLabel = new JLabel(fb.getTitle()); GridBagConstraints titleLabelConst = new GridBagConstraints(); titleLabelConst.anchor = GridBagConstraints.CENTER; titleLabelConst.gridx = 1; titleLabelConst.gridy = 0; titleLabelConst.weightx = 1.0; Font titleLabelFont = titleLabel.getFont(); titleLabel.setFont( new Font( titleLabelFont.getName(), Font.BOLD, titleLabelFont.getSize() + 4)); // increase label font size by 2 JLabel descLabel = new JLabel(fb.getDescription()); GridBagConstraints descLabelConst = new GridBagConstraints(); descLabelConst.anchor = GridBagConstraints.CENTER; descLabelConst.gridx = 1; descLabelConst.gridy = 1; descLabelConst.weightx = 1.0; JLabel exclLabel = new JLabel("!"); exclLabel.setAlignmentX(RIGHT_ALIGNMENT); exclLabel.setToolTipText("Response is mandatory"); try { exclLabel.setFont(loadGlyphFont(titleLabelFont.getSize() + 4)); exclLabel.setText("\ue101"); } catch (FontFormatException | IOException e) { e.printStackTrace(); } GridBagConstraints rightBoxConst = new GridBagConstraints(); rightBoxConst.anchor = GridBagConstraints.LINE_END; rightBoxConst.gridx = 2; rightBoxConst.gridy = 0; rightBoxConst.gridheight = 2; rightBoxConst.ipadx = 4; questionPanel.add(new JPanel(), leftBoxConst); questionPanel.add(titleLabel, titleLabelConst); questionPanel.add(descLabel, descLabelConst); questionPanel.add(fb.isMandatory() ? exclLabel : new JPanel(), rightBoxConst); return questionPanel; }
/* * Creation du panel de la legende */ private JPanel createPanelLegende() { JPanel panelLegende = new JPanel(); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.HORIZONTAL; c.gridheight = 1; c.gridwidth = 1; c.gridx = 0; c.gridy = GridBagConstraints.RELATIVE; c.weightx = 0; c.weighty = 0; c.insets = new Insets(2, 0, 0, 0); GridBagConstraints cPanel = new GridBagConstraints(); cPanel.anchor = GridBagConstraints.NORTHWEST; cPanel.fill = GridBagConstraints.HORIZONTAL; cPanel.gridheight = 1; cPanel.gridwidth = 1; cPanel.gridx = 0; cPanel.gridy = GridBagConstraints.RELATIVE; cPanel.weightx = 0; cPanel.weighty = 0; cPanel.insets = new Insets(0, 0, 0, 0); panelLegende.setLayout(new GridBagLayout()); panelLegende.setBorder(BorderFactory.createTitledBorder("Légendes")); JPanel ecritureValidPanel = new JPanel(); ecritureValidPanel.setLayout(new GridBagLayout()); ecritureValidPanel.setBackground(Color.WHITE); ecritureValidPanel.add(new JLabel("Ecritures validées"), cPanel); panelLegende.add(ecritureValidPanel, c); JPanel ecritureNonValidPanel = new JPanel(); ecritureNonValidPanel.setLayout(new GridBagLayout()); ecritureNonValidPanel.setBackground(PointageRenderer.getCouleurEcritureNonValide()); ecritureNonValidPanel.add(new JLabel("Ecritures non validées"), cPanel); panelLegende.add(ecritureNonValidPanel, c); JPanel ecritureNonValidTodayPanel = new JPanel(); ecritureNonValidTodayPanel.setLayout(new GridBagLayout()); ecritureNonValidTodayPanel.setBackground(PointageRenderer.getCouleurEcritureToDay()); ecritureNonValidTodayPanel.add(new JLabel("Ecritures non validées du jour"), cPanel); panelLegende.add(ecritureNonValidTodayPanel, c); JPanel ecriturePointePanel = new JPanel(); ecriturePointePanel.setLayout(new GridBagLayout()); ecriturePointePanel.setBackground(PointageRenderer.getCouleurEcriturePointee()); ecriturePointePanel.add(new JLabel("Ecritures lettrées"), cPanel); panelLegende.add(ecriturePointePanel, c); return panelLegende; }
protected Component buildMainPanel() { JPanel messagePanel = new JPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); JPanel queryVarietyPanel = buildQueryVarietyPanel(); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 0, 0, 0); messagePanel.add(queryVarietyPanel, constraints); helpManager().addTopicID(queryVarietyPanel, helpTopicId() + ".ejb20"); JPanel queryTypePanel = buildQueryTypePanel(); constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 0, 0, 0); messagePanel.add(queryTypePanel, constraints); helpManager().addTopicID(queryTypePanel, helpTopicId() + ".type"); // name panel JPanel namePanel = buildNamePanel(); constraints.gridx = 0; constraints.gridy = 2; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(15, 5, 0, 5); messagePanel.add(namePanel, constraints); helpManager().addTopicID(namePanel, helpTopicId() + ".name"); getOKAction().setEnabled(false); return messagePanel; }
protected void build() { setLayout(new GridBagLayout()); GridBagConstraints gc = new GridBagConstraints(); // --------------------------- gc.gridx = 0; gc.gridy = 0; gc.gridwidth = 1; gc.gridheight = 1; gc.weightx = 0.5; gc.weighty = 0.0; gc.insets = new Insets(5, 5, 5, 0); gc.fill = GridBagConstraints.HORIZONTAL; gc.anchor = GridBagConstraints.FIRST_LINE_START; referenceInfoPanel = new VersionInfoPanel(model, PointInTimeType.REFERENCE_POINT_IN_TIME); add(referenceInfoPanel, gc); gc.gridx = 1; gc.gridy = 0; gc.gridwidth = 1; gc.gridheight = 1; gc.fill = GridBagConstraints.HORIZONTAL; gc.weightx = 0.5; gc.weighty = 0.0; gc.anchor = GridBagConstraints.FIRST_LINE_START; currentInfoPanel = new VersionInfoPanel(model, PointInTimeType.CURRENT_POINT_IN_TIME); add(currentInfoPanel, gc); adjustmentSynchronizer = new AdjustmentSynchronizer(); selectionSynchronizer = new SelectionSynchronizer(); // --------------------------- gc.gridx = 0; gc.gridy = 1; gc.gridwidth = 1; gc.gridheight = 1; gc.weightx = 0.5; gc.weighty = 1.0; gc.fill = GridBagConstraints.BOTH; gc.anchor = GridBagConstraints.NORTHWEST; add(embeddInScrollPane(buildReferenceMemberListTable()), gc); gc.gridx = 1; gc.gridy = 1; gc.gridwidth = 1; gc.gridheight = 1; gc.weightx = 0.5; gc.weighty = 1.0; gc.fill = GridBagConstraints.BOTH; gc.anchor = GridBagConstraints.NORTHWEST; add(embeddInScrollPane(buildCurrentMemberListTable()), gc); }
/** * Adds contact entry labels. * * @param nameLabelGridWidth the grid width of the contact entry name label */ private void addLabels(int nameLabelGridWidth) { remove(nameLabel); remove(rightLabel); remove(displayDetailsLabel); if (treeNode != null && !(treeNode instanceof GroupNode)) constraints.insets = new Insets(0, 0, V_GAP, H_GAP); else constraints.insets = new Insets(0, 0, 0, H_GAP); constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 0; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridheight = 1; constraints.gridwidth = nameLabelGridWidth; this.add(nameLabel, constraints); constraints.anchor = GridBagConstraints.NORTHEAST; constraints.fill = GridBagConstraints.VERTICAL; constraints.gridx = nameLabelGridWidth + 1; constraints.gridy = 0; constraints.gridheight = 3; constraints.weightx = 0f; constraints.weighty = 1f; this.add(rightLabel, constraints); if (treeNode != null && treeNode instanceof ContactNode) { constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = nameLabelGridWidth; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); } else if (treeNode != null && treeNode instanceof GroupNode) { constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = nameLabelGridWidth; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); } }
private void initializeLayout(ValueModel basicExpressionEnablerModel) { setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); Collection enablingComponents = new ArrayList(); JLabel queryKeyLabel = new JLabel(resourceRepository().getString("QUERY_KEY_LABEL_ON_FIRST_ARGUMENT_PANEL")); enablingComponents.add(queryKeyLabel); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.insets = new Insets(5, 5, 0, 5); this.add(queryKeyLabel, constraints); this.queryKeyTextField = buildQueryableTextField(); enablingComponents.add(queryKeyTextField); constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.insets = new Insets(5, 5, 5, 5); add(this.queryKeyTextField, constraints); this.editQueryKeyButton = new JButton( resourceRepository().getString("QUERY_KEY_EDIT_BUTTON_ON_FIRST_ARGUMENT_PANEL")); editQueryKeyButton.setMnemonic( resourceRepository().getMnemonic("QUERY_KEY_EDIT_BUTTON_ON_FIRST_ARGUMENT_PANEL")); this.editQueryKeyButton.addActionListener(buildEditQueryKeyAction()); enablingComponents.add(editQueryKeyButton); new ComponentEnabler(basicExpressionEnablerModel, enablingComponents); constraints.gridx = 1; constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 1; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.insets = new Insets(5, 5, 5, 5); add(this.editQueryKeyButton, constraints); }
protected GridBagConstraints createConstraints(int x, int y) { GridBagConstraints c = new GridBagConstraints(); c.gridx = x; c.gridy = y; c.gridwidth = 2; c.gridheight = 1; c.ipadx = 1; c.weightx = 0.5; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; return c; }
// Initializing this component. private void jbInit() { callStackTable.addFocusListener( new FocusListener() { public void focusGained(FocusEvent e) { callStackTable_focusGained(e); } public void focusLost(FocusEvent e) { callStackTable_focusLost(e); } }); callStackTable.setTableHeader(null); callStackTable.setDefaultRenderer(callStackTable.getColumnClass(0), getCellRenderer()); scrollPane = new JScrollPane(callStackTable); setVisibleRows(DEFAULT_VISIBLE_ROWS); scrollPane.setLocation(0, 27); setBorder(BorderFactory.createEtchedBorder()); // this.setLayout(null); this.setLayout(new GridBagLayout()); nameLbl.setText("Call Stack"); nameLbl.setBounds(new Rectangle(3, 4, 70, 23)); nameLbl.setFont(Utilities.labelsFont); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = 7; c.gridheight = 1; c.anchor = GridBagConstraints.PAGE_END; c.gridx = 0; c.gridy = 2; this.add(scrollPane, c); c.fill = GridBagConstraints.HORIZONTAL; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 0.0; c.gridwidth = 3; c.gridheight = 1; c.anchor = GridBagConstraints.FIRST_LINE_START; c.gridx = 0; c.gridy = 0; c.insets = new Insets(5, 0, 0, 0); this.add(nameLbl, c); }
private void makeGridPanel(Component[] components) { final Insets insets = new Insets(5, 5, 5, 5); final GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.insets = insets; gbc.ipadx = 0; gbc.ipady = 0; gbc.anchor = GridBagConstraints.EAST; gbc.fill = GridBagConstraints.HORIZONTAL; int i = 0; int j = 0; for (Component component : components) { gbc.gridx = i; gbc.gridy = j; gbc.gridwidth = 1; gbc.gridheight = 1; centerPanel.add(component, gbc); i++; // 2 components per row if ((i % 2) == 0) { j++; i = 0; } } }
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jLabel1 = new javax.swing.JLabel(); folderPanel = new javax.swing.JPanel(); setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 12, 12)); setLayout(new java.awt.GridBagLayout()); jLabel1.setText( org.openide.util.NbBundle.getMessage(BrowseFolders.class, "LBL_Folders")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 0); add(jLabel1, gridBagConstraints); folderPanel.setLayout(new java.awt.BorderLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(folderPanel, gridBagConstraints); } // </editor-fold>//GEN-END:initComponents
public static void addComponent( Container container, Component component, int gridx, int gridy, int gridwidth, int gridheight, int fill, int anchor) throws AWTException { LayoutManager lm = container.getLayout(); if (!(lm instanceof GridBagLayout)) { throw new AWTException("Invalid layout" + lm); } else { GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = gridx; gbc.gridy = gridy; gbc.gridwidth = gridwidth; gbc.gridheight = gridheight; gbc.fill = fill; gbc.anchor = anchor; ((GridBagLayout) lm).setConstraints(component, gbc); container.add(component); } }
private void initGUI() { Panel pEntry = new Panel(); pEntry.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(3, 3, 3, 3); c.gridwidth = 1; c.gridheight = 1; c.weightx = c.weighty = 1; c.anchor = GridBagConstraints.WEST; komponente = new ZaurusComponent[columns.length]; for (int i = 0; i < columns.length; i++) { c.gridy = i; c.gridx = 0; pEntry.add(new Label((String) columns[i]), c); c.gridx = 1; int constraint = this.getConstraintIndex(i); if (constraint >= 0 && imColIndex[constraint].length == 1) { // we use ony foreign keys with one index ZaurusChoice tmp = new ZaurusChoice(); this.fillZChoice(tmp, refTables[constraint], refColumns[constraint][0]); tmp.addItemListener(this); komponente[i] = tmp; pEntry.add(tmp, c); } else if (columnTypes[i] == java.sql.Types.DATE) { // System.out.println("hier gibt es eine Date-Spalte namens "+columns[i]); ZaurusTextField tmp = new ZaurusTextField(8); tmp.addTextListener(this); pEntry.add(tmp, c); komponente[i] = tmp; } else { ZaurusTextField tmp = new ZaurusTextField(5); tmp.addTextListener(this); pEntry.add(tmp, c); komponente[i] = tmp; } komponente[i].setEditable(true); } this.add(pEntry); }
protected void guiMount() { this.pack(); int proportion = (int) Math.round(this.getWidth() * 0.15); // put Ok and Cancel buttons, standard for all subclasses this.buttonPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(8, 0, 8, proportion); this.buttonPanel.add(this.okButton, gbc); gbc.gridx = 1; gbc.insets = new Insets(8, proportion, 8, 0); this.buttonPanel.add(this.cancelButton, gbc); this.build(); this.pack(); int width = Toolkit.getDefaultToolkit().getScreenSize().width; int height = Toolkit.getDefaultToolkit().getScreenSize().height; this.setLocation( Math.round(width / 2 - this.getWidth() / 2), Math.round(height / 2 - this.getHeight() / 2)); }
private static JPanel makePanel(String title, String href) { JPanel p = new JPanel(new GridBagLayout()); p.setBorder(BorderFactory.createTitledBorder(title)); JLabel label = new JLabel(href); JEditorPane editor = new JEditorPane("text/html", href); editor.setOpaque(false); editor.setEditable(false); editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); GridBagConstraints c = new GridBagConstraints(); c.gridheight = 1; c.gridx = 0; c.insets = new Insets(5, 5, 5, 0); c.anchor = GridBagConstraints.EAST; c.gridy = 0; p.add(new JLabel("JLabel: "), c); c.gridy = 2; p.add(new JLabel("JEditorPane: "), c); c.gridx = 1; c.weightx = 1d; c.anchor = GridBagConstraints.WEST; c.gridy = 0; p.add(label, c); c.gridy = 2; p.add(editor, c); return p; }
private void setActiveArgumentPanel(ArgumentPanel newArgumentPanel) { JPanel oldActiveArgumentPanel = this.activeArgumentPanel; if (newArgumentPanel == oldActiveArgumentPanel) return; this.activeArgumentPanel = newArgumentPanel; if (oldActiveArgumentPanel != null) this.emptyPanel.remove(oldActiveArgumentPanel); GridBagConstraints constraints = new GridBagConstraints(); this.emptyPanel.setLayout(new GridBagLayout()); constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 0; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.FIRST_LINE_START; constraints.insets = new Insets(0, 5, 0, 5); this.emptyPanel.add(this.activeArgumentPanel, constraints); revalidate(); repaint(); }
private void initializeLayout() { this.setBorder( BorderFactory.createCompoundBorder( buildTitledBorder("PRIMARY_KEYS_PANEL.TITLE"), BorderFactory.createEmptyBorder(0, 5, 5, 5))); GridBagConstraints constraints = new GridBagConstraints(); // primary keys - add/remove list panel AddRemoveListPanel pane = this.buildPrimaryKeysList(); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(0, 0, 0, 0); this.add(pane, constraints); this.addPaneForAlignment(pane); addHelpTopicId(this, this.helpTopicId()); }