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:org.openmrs.test.BaseContextSensitiveTest.java
/** * Utility method for obtaining username and password through Swing interface for tests. Any * tests extending the org.openmrs.BaseTest class may simply invoke this method by name. * Username and password are returned in a two-member String array. If the user aborts, null is * returned. <b> <em>Do not call for non-interactive tests, since this method will try to * render an interactive dialog box for authentication!</em></b> * //from w w w.j a va 2s .c o m * @param message string to display above username field * @return Two-member String array containing username and password, respectively, or * <code>null</code> if user aborts dialog */ public static synchronized String[] askForUsernameAndPassword(String message) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } if (message == null || "".equals(message)) message = "Enter username/password to authenticate to OpenMRS..."; JPanel panel = new JPanel(new GridBagLayout()); JLabel usernameLabel = new JLabel("Username"); usernameLabel.setFont(font); usernameField = new JTextField(20); usernameField.setFont(font); JLabel passwordLabel = new JLabel("Password"); passwordLabel.setFont(font); JPasswordField passwordField = new JPasswordField(20); passwordField.setFont(font); panel.add(usernameLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 5, 0)); panel.add(usernameField, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); panel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 5, 0)); panel.add(passwordField, new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); frame = new JFrame(); Window window = new Window(frame); frame.setVisible(true); frame.setTitle("JUnit Test Credentials"); // We use a TimerTask to force focus on username, but still use // JOptionPane for model dialog TimerTask later = new TimerTask() { @Override public void run() { if (frame != null) { // bring the dialog's window to the front frame.toFront(); usernameField.grabFocus(); } } }; // try setting focus half a second from now new Timer().schedule(later, 500); // attention grabber for those people that aren't as observant TimerTask laterStill = new TimerTask() { @Override public void run() { if (frame != null) { frame.toFront(); // bring the dialog's window to the // front usernameField.grabFocus(); } } }; // if the user hasn't done anything in 10 seconds, tell them the window // is there new Timer().schedule(laterStill, 10000); // show the dialog box int response = JOptionPane.showConfirmDialog(window, panel, message, JOptionPane.OK_CANCEL_OPTION); // clear out the window so the timer doesn't screw up laterStill.cancel(); frame.setVisible(false); window.setVisible(false); frame = null; // response of 2 is the cancel button, response of -1 is the little red // X in the top right return (response == 2 || response == -1 ? null : new String[] { usernameField.getText(), String.valueOf(passwordField.getPassword()) }); }
From source file:net.sourceforge.squirrel_sql.client.preferences.UpdatePreferencesPanel.java
/** * Sets the specified GridBagConstraints with the specified grid y coordinate and:<br> * <br>/*from w w w . j a va 2 s . c o m*/ * grid x = 0 <br> * grid width = 2 <br> * weight x = 1 <br> * insets = SEP_INSETS <br> * fill = GridBagConstraints.HORIZONTAL <br> * anchor = GridBagConstraints.WEST * * @param gbc * the constraints to set * @param gridy * the grid y coordinate */ private void setSeparatorConstraints(GridBagConstraints gbc, int gridy) { gbc.gridx = 0; gbc.gridy = gridy; gbc.gridwidth = 2; gbc.weightx = 1; gbc.insets = SEP_INSETS; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.WEST; }
From source file:com.sec.ose.osi.ui.dialog.setting.JPanProjectAnalysisSetting.java
/** * This method initializes jPanel //from ww w . j av a 2s. com * * @return javax.swing.JPanel */ private JPanel getJPanel() { if (jPanel == null) { GridBagConstraints gridBagConstraints17 = new GridBagConstraints(); gridBagConstraints17.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints17.weighty = 0.0; gridBagConstraints17.weightx = 0.0; gridBagConstraints17.insets = new Insets(0, 0, 10, 0); gridBagConstraints17.anchor = GridBagConstraints.NORTH; GridBagConstraints gridBagConstraints16 = new GridBagConstraints(); gridBagConstraints16.gridx = 0; gridBagConstraints16.anchor = GridBagConstraints.NORTH; gridBagConstraints16.weighty = 0.0; gridBagConstraints16.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints16.weightx = 0.0; gridBagConstraints16.gridy = 1; jPanel = new JPanel(); jPanel.setLayout(new GridBagLayout()); jPanel.add(getJButtonOK(), gridBagConstraints17); jPanel.add(getJButtonCancel(), gridBagConstraints16); } return jPanel; }
From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.SearchPanel.java
/** * Builds the UI component hosting the time interval. * // www. j av a 2 s.c o m * @return See above. */ private JPanel buildDate() { JPanel p = new JPanel(); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; dateBox = new JComboBox(); dateBox.setToolTipText(DATE_TYPE_TOOLTIP); dateBox.addItem(ITEM_IMPORTDATE); dateBox.addItem(ITEM_ACQUISITIONDATE); p.add(dateBox); c.gridy++; p.add(buildTimeRange(), c); UIUtilities.setBoldTitledBorder("Date", p); return p; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java
/** Builds and lays out the UI. */ private void buildGUI() { removeAll();/*from w w w .ja v a 2s .com*/ JLabel l = new JLabel(); Font f = l.getFont(); int size = f.getSize() - 1; content.removeAll(); content.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 1, 2, 1); c.anchor = GridBagConstraints.WEST; c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = 2; c.fill = GridBagConstraints.HORIZONTAL; if (!model.isAnnotationLoaded()) { l.setText("Annotation could not be loaded"); content.add(l, c); return; } if (model.isMultiSelection()) { Object refObject = model.getRefObject(); StringBuffer buffer = new StringBuffer(); buffer.append("Annotate the selected "); buffer.append(model.getObjectTypeAsString(refObject)); buffer.append("s"); l.setText(buffer.toString()); content.add(l, c); c.gridy++; } // filters content.add(createBar(filterButton, null), c); c.gridy++; // rating c.gridwidth = 1; c.gridx = 0; c.weightx = 0; c.fill = GridBagConstraints.NONE; JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(UIUtilities.setTextFont("Rating:", Font.BOLD, size)); p.add(createBar(unrateButton, null)); content.add(p, c); c.gridx = 1; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(rating); p.add(Box.createHorizontalStrut(2)); p.add(otherRating); content.add(p, c); c.gridy++; // tags c.gridx = 0; p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(UIUtilities.setTextFont("Tags:", Font.BOLD, size)); p.add(createBar(addTagsButton, removeTagsButton)); content.add(p, c); c.gridy++; content.add(tagsPane, c); c.gridy++; // attachment c.gridx = 0; c.gridwidth = 2; p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(UIUtilities.setTextFont("Attachments:", Font.BOLD, size)); p.add(createBar(addDocsButton, removeDocsButton)); content.add(p, c); c.gridy++; content.add(docRef, c); c.gridy++; if (!model.isMultiSelection()) { mapsPane.reload(filter); content.add(mapsPane, c); c.gridy++; } // other if (!CollectionUtils.isEmpty(model.getAllOtherAnnotations())) { p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(UIUtilities.setTextFont("Others:", Font.BOLD, size)); p.add(createBar(null, removeOtherAnnotationsButton)); content.add(p, c); c.gridy++; content.add(otherPane, c); } add(content, BorderLayout.CENTER); }
From source file:com.sec.ose.osi.ui.frm.main.manage.JPanManageMain.java
/** * This method initializes jPanelButton * /*w ww .j av a 2 s .co m*/ * @return javax.swing.JPanel */ private JPanel getJPanelButton() { if (jPanelButton == null) { GridBagConstraints gridBagConstraints7 = new GridBagConstraints(); gridBagConstraints7.insets = new Insets(10, 10, 10, 10); GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.gridx = 0; gridBagConstraints3.insets = new Insets(10, 10, 10, 10); gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints3.gridy = 1; jPanelButton = new JPanel(); jPanelButton.setLayout(new GridBagLayout()); jPanelButton.add(getJButtonAnalyze(), gridBagConstraints7); jPanelButton.add(getJButtonCancel(), gridBagConstraints3); } return jPanelButton; }
From source file:com.sec.ose.osi.ui.frm.login.JPanLogin.java
/**************** * Proxy Info//from w w w.j a v a 2 s . c o m ***************/ private JPanel getJPanelForProxyInfo() { if (jPanelForProxyInfo == null) { GridBagConstraints gridBagConstraintsProxyInfo = new GridBagConstraints(); gridBagConstraintsProxyInfo.fill = GridBagConstraints.HORIZONTAL; gridBagConstraintsProxyInfo.gridx = -1; gridBagConstraintsProxyInfo.gridy = -1; gridBagConstraintsProxyInfo.gridwidth = 1; gridBagConstraintsProxyInfo.anchor = GridBagConstraints.CENTER; gridBagConstraintsProxyInfo.weightx = 1.0; gridBagConstraintsProxyInfo.weighty = 0.0; //gridBagConstraints5.insets = new Insets(10, 10, 0, 20); jPanelForProxyInfo = new JPanel(); jPanelForProxyInfo.setLayout(new GridBagLayout()); jPanelForProxyInfo.setBorder(BorderFactory.createTitledBorder(null, "Proxy Setting", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51))); jPanelForProxyInfo.add(getJPanelProxyInfo(), gridBagConstraintsProxyInfo); } return jPanelForProxyInfo; }
From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.SearchPanel.java
/** Builds and lays out the UI. */ private void buildGUI() { setBorder(null);//from w w w . ja v a 2s.c o m setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 2, 2, 0); c.gridy = 0; c.gridx = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; setBackground(UIUtilities.BACKGROUND_COLOR); add(buildSearchFor(), c);// , "0, 0"); SeparatorPane sep = new SeparatorPane(); sep.setBackground(UIUtilities.BACKGROUND_COLOR); c.gridy++; add(sep, c);// , "0, 1"); JPanel typePanel = buildType(); c.gridy++; add(typePanel, c);// , "0, 2") JPanel fieldsPanel = buildFields(); c.gridy++; add(fieldsPanel, c);// , "0, 2"); JPanel scopePanel = buildScope(); c.gridy++; add(scopePanel, c);// , "0, 2"); JPanel datePanel = buildDate(); c.gridy++; add(datePanel, c);// , "0, 4"); updateUsersBox(); }
From source file:it.cnr.icar.eric.client.ui.swing.AdhocQuerySearchPanel.java
private JPanel createParameterEntryPanel(QueryType uiQueryType) { JPanel parameterEntryPanel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); parameterEntryPanel.setLayout(gbl);/*from w w w . j av a2 s .c o m*/ paramComponents.clear(); List<?> params = uiQueryType.getParameter(); Iterator<?> iter = params.iterator(); int i = 0; while (iter.hasNext()) { ParameterType param = (ParameterType) iter.next(); String tooltip = getLocalizedValue(param.getDescription()); JLabel label = new JLabel(getLocalizedValue(param.getName()) + ":", SwingConstants.LEADING); label.setToolTipText(tooltip); c.gridx = 0; c.gridy = i; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_END; c.insets = new Insets(4, 4, 0, 4); gbl.setConstraints(label, c); parameterEntryPanel.add(label); //Get default value for Parameter if any String defaultValue = param.getDefaultValue(); JComponent comp = getComponentForParameter(param, defaultValue); //comp.setToolTipText(tooltip); c.gridx = 1; c.gridy = i; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.5; c.weighty = 0.0; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.LINE_END; c.insets = new Insets(4, 4, 4, 4); gbl.setConstraints(comp, c); parameterEntryPanel.add(comp); paramComponents.add(comp); i++; } return parameterEntryPanel; }
From source file:org.jets3t.apps.cockpit.Cockpit.java
/** * Initialises the application's GUI elements. *///from w w w. j a v a 2 s . c om private void initGui() { initMenus(); JPanel appContent = new JPanel(new GridBagLayout()); this.getContentPane().add(appContent); // Buckets panel. JPanel bucketsPanel = new JPanel(new GridBagLayout()); JButton bucketActionButton = new JButton(); bucketActionButton.setToolTipText("Bucket actions menu"); guiUtils.applyIcon(bucketActionButton, "/images/nuvola/16x16/actions/misc.png"); bucketActionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JButton sourceButton = (JButton) e.getSource(); bucketActionMenu.show(sourceButton, 0, sourceButton.getHeight()); } }); bucketsPanel.add(new JHtmlLabel("<html><b>Buckets</b></html>", this), new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); bucketsPanel.add(bucketActionButton, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); bucketTableModel = new BucketTableModel(false); bucketTableModelSorter = new TableSorter(bucketTableModel); bucketsTable = new JTable(bucketTableModelSorter); bucketTableModelSorter.setTableHeader(bucketsTable.getTableHeader()); bucketsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); bucketsTable.getSelectionModel().addListSelectionListener(this); bucketsTable.setShowHorizontalLines(true); bucketsTable.setShowVerticalLines(false); bucketsTable.addMouseListener(new ContextMenuListener()); bucketsPanel.add(new JScrollPane(bucketsTable), new GridBagConstraints(0, 1, 2, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); bucketsPanel.add(new JLabel(" "), new GridBagConstraints(0, 2, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); // Filter panel. filterObjectsPanel = new JPanel(new GridBagLayout()); filterObjectsPrefix = new JTextField(); filterObjectsPrefix.setToolTipText("Only show objects with this prefix"); filterObjectsPrefix.addActionListener(this); filterObjectsPrefix.setActionCommand("RefreshObjects"); filterObjectsDelimiter = new JComboBox(new String[] { "", "/", "?", "\\" }); filterObjectsDelimiter.setEditable(true); filterObjectsDelimiter.setToolTipText("Object name delimiter"); filterObjectsDelimiter.addActionListener(this); filterObjectsDelimiter.setActionCommand("RefreshObjects"); filterObjectsPanel.add(new JHtmlLabel("Prefix:", this), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); filterObjectsPanel.add(filterObjectsPrefix, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); filterObjectsPanel.add(new JHtmlLabel("Delimiter:", this), new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0)); filterObjectsPanel.add(filterObjectsDelimiter, new GridBagConstraints(3, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); filterObjectsPanel.setVisible(false); // Objects panel. JPanel objectsPanel = new JPanel(new GridBagLayout()); int row = 0; filterObjectsCheckBox = new JCheckBox("Filter objects"); filterObjectsCheckBox.addActionListener(this); filterObjectsCheckBox.setToolTipText("Check this option to filter the objects listed"); objectsPanel.add(new JHtmlLabel("<html><b>Objects</b></html>", this), new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); objectsPanel.add(filterObjectsCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); JButton objectActionButton = new JButton(); objectActionButton.setToolTipText("Object actions menu"); guiUtils.applyIcon(objectActionButton, "/images/nuvola/16x16/actions/misc.png"); objectActionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JButton sourceButton = (JButton) e.getSource(); objectActionMenu.show(sourceButton, 0, sourceButton.getHeight()); } }); objectsPanel.add(objectActionButton, new GridBagConstraints(2, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); objectsPanel.add(filterObjectsPanel, new GridBagConstraints(0, ++row, 3, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); objectsTable = new JTable(); objectTableModel = new ObjectTableModel(); objectTableModelSorter = new TableSorter(objectTableModel); objectTableModelSorter.setTableHeader(objectsTable.getTableHeader()); objectsTable.setModel(objectTableModelSorter); objectsTable.setDefaultRenderer(Long.class, new DefaultTableCellRenderer() { private static final long serialVersionUID = 301092191828910402L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { String formattedSize = byteFormatter.formatByteSize(((Long) value).longValue()); return super.getTableCellRendererComponent(table, formattedSize, isSelected, hasFocus, row, column); } }); objectsTable.setDefaultRenderer(Date.class, new DefaultTableCellRenderer() { private static final long serialVersionUID = 7285511556343895652L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Date date = (Date) value; return super.getTableCellRendererComponent(table, yearAndTimeSDF.format(date), isSelected, hasFocus, row, column); } }); objectsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); objectsTable.getSelectionModel().addListSelectionListener(this); objectsTable.setShowHorizontalLines(true); objectsTable.setShowVerticalLines(true); objectsTable.addMouseListener(new ContextMenuListener()); objectsTableSP = new JScrollPane(objectsTable); objectsPanel.add(objectsTableSP, new GridBagConstraints(0, ++row, 3, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); objectsSummaryLabel = new JHtmlLabel("Please select a bucket", this); objectsSummaryLabel.setHorizontalAlignment(JLabel.CENTER); objectsSummaryLabel.setFocusable(false); objectsPanel.add(objectsSummaryLabel, new GridBagConstraints(0, ++row, 3, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); // Combine sections. JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, bucketsPanel, objectsPanel); splitPane.setOneTouchExpandable(true); splitPane.setContinuousLayout(true); appContent.add(splitPane, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); // Set preferred sizes int preferredWidth = 800; int preferredHeight = 600; this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight))); splitPane.setResizeWeight(0.30); // Initialize drop target. initDropTarget(new JComponent[] { objectsTableSP, objectsTable }); objectsTable.getDropTarget().setActive(false); objectsTableSP.getDropTarget().setActive(false); }