下面列出了java.awt.GridBagConstraints#WEST 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void addGridBagLayer(JPanel panel, Font font, Insets insets, String text, JComponent comp)
{
GridBagConstraints gbc = new GridBagConstraints();
JLabel label = new JLabel(LanguageBundle.getString(text));
label.setFont(font);
gbc.anchor = GridBagConstraints.WEST;
gbc.gridwidth = 2;
panel.add(label, gbc);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.fill = GridBagConstraints.BOTH;
if (insets != null)
{
gbc.insets = insets;
}
panel.add(comp, gbc);
}
protected Component createContentPane() {
final JPanel contentPane = new JPanel();
contentPane.setLayout( new GridBagLayout() );
final GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
c.weightx = 0.0;
c.insets = new Insets( 5, 10, 0, 10 );
contentPane.add( new JLabel( Messages.getInstance().getString( "CreateNewRepositoryFolderDialog.Name" ) ), c );
c.gridx = 0;
c.gridy = 1;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.WEST;
c.weightx = 1.0;
c.insets = new Insets( 0, 10, 5, 10 );
contentPane.add( nameTextField, c );
c.gridx = 0;
c.gridy = 2;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
c.weightx = 0.0;
c.insets = new Insets( 5, 10, 0, 10 );
contentPane
.add( new JLabel( Messages.getInstance().getString( "CreateNewRepositoryFolderDialog.Description" ) ), c );
c.gridx = 0;
c.gridy = 3;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
c.weightx = 1.0;
c.insets = new Insets( 0, 10, 5, 10 );
contentPane.add( descTextField, c );
return contentPane;
}
private void addLineCommentTextField(JPanel panel, int col, int row)
{
GridBagConstraints c = new GridBagConstraints();
c.gridx = col;
c.gridy = row;
c.ipadx = 40; // Increases component width by 40 pixels
c.insets = new Insets(5, 5, 0, 0);
c.anchor = GridBagConstraints.WEST;
lineCommentTextField = new JTextField(10);
lineCommentTextField.setName("lineCommentTextField");
lineCommentTextField.setHorizontalAlignment(JTextField.RIGHT);
lineCommentTextField.setToolTipText(i18n.LINE_COMMENT_LABEL_TT);
panel.add(lineCommentTextField, c);
}
/**
* Worker method that adds a label - control pair to the UI (e.g. wind - wind dropdown)
* @param c GridBagConstraints to use
* @param label The label to add
* @param valueControl The textbox or dropdown to add
*/
private void addLabelControlPair(GridBagConstraints c, JLabel label, JComponent valueControl) {
c.gridwidth = 1;
c.anchor = GridBagConstraints.EAST;
panOptions.add(label, c);
label.setLabelFor(valueControl);
c.gridwidth = GridBagConstraints.REMAINDER;
c.anchor = GridBagConstraints.WEST;
panOptions.add(valueControl, c);
}
private JPanel makeInputPanel() {
GridBagConstraints gbConst = new GridBagConstraints();
gbConst.anchor = GridBagConstraints.WEST;
gbConst.insets = new Insets(5, 5, 5, 5);
JLabel pathLabel = new JLabel("Download To:");
gbConst.gridwidth = 1;
inputPanel.add(pathLabel, gbConst);
addStrut();
inputPanel.add(pathField, gbConst);
addStrut();
JButton browse = new JButton("Browse ...");
browse.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
int returnVal = fileChooser.showOpenDialog(DownloadServerLogDialog.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
setPathField();
}
}
});
gbConst.gridwidth = GridBagConstraints.REMAINDER;
inputPanel.add(browse, gbConst);
if (openInViewerSupported) {
JLabel emptyLabel = new JLabel("");
gbConst.gridwidth = 1;
inputPanel.add(emptyLabel, gbConst);
addStrut();
gbConst.gridwidth = GridBagConstraints.REMAINDER;
inputPanel.add(viewInLogViewer, gbConst);
}
return inputPanel;
}
/**
* Create a description panel.
*/
private JPanel createDescriptionPanel(String header, String description, boolean showDescription) {
JPanel descPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
JLabel headerLabel = new JLabel(header);
headerLabel.setFont(OPEN_SANS_SEMIBOLD_14);
descPanel.add(headerLabel, gbc);
if (showDescription) {
gbc.gridy += 1;
JLabel descLabel = new FixedWidthLabel(300, description);
descLabel.setFont(OPEN_SANS_12);
descPanel.add(descLabel, gbc);
if (!isTypeKnown) {
descLabel.setForeground(UNKNOWN_TYPE_COLOR);
}
}
gbc.gridy += 1;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.VERTICAL;
descPanel.add(new JLabel(), gbc);
if (!isTypeKnown) {
headerLabel.setForeground(UNKNOWN_TYPE_COLOR);
}
return descPanel;
}
private void addLineCommentLabel(JPanel panel, int col, int row)
{
GridBagConstraints c = new GridBagConstraints();
c.gridx = col;
c.gridy = row;
c.insets = new Insets(5, LEFT_INDENT_INSET_SIZE, 0, 0);
c.anchor = GridBagConstraints.WEST;
lineCommentLabel = new JLabel(i18n.LINE_COMMENT_LABEL);
lineCommentLabel.setHorizontalAlignment(JLabel.LEFT);
lineCommentLabel.setToolTipText(i18n.LINE_COMMENT_LABEL_TT);
panel.add(lineCommentLabel, c);
}
private void prepareNewRow(final GridBagConstraints gbc)
{
gbc.gridx = 0;
++gbc.gridy;
gbc.anchor = GridBagConstraints.WEST;
gbc.gridwidth = 1;
}
public DoubleSlider(int[] realMinMax, int[] setMinMax, Color color) {
super();
minTF.setIntegersOnly(true);
minTF.addListener(this);
minTF.addNumberFieldFocusListener(this);
maxTF.setIntegersOnly(true);
maxTF.addListener(this);
maxTF.addNumberFieldFocusListener(this);
this.slider = new DoubleSliderCanvas(realMinMax, setMinMax, color, this);
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
setLayout(gridbag);
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
c.insets = new Insets(0, 2, 0, 5);
c.weightx = 1.0;
add(slider, c);
c.fill = GridBagConstraints.NONE;
c.weightx = 0;
c.gridwidth = 1;
c.insets = new Insets(3, 3, 0, 3);
c.gridx = 1;
c.anchor = GridBagConstraints.WEST;
add(minTF, c);
c.gridx = 2;
c.anchor = GridBagConstraints.EAST;
add(maxTF, c);
updateTextfieldsFromSliders();
}
private GridBagConstraints getFieldConstraints(GridBagConstraints c) {
c.gridx++;
c.anchor = GridBagConstraints.WEST;
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.NONE;
return c;
}
private JScrollPane makeInputPanel() {
boolean hasRequiredFields = false;
JPanel inputPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbConst = new GridBagConstraints();
gbConst.anchor = GridBagConstraints.WEST;
gbConst.insets = new Insets(5,5,5,5);
for (RequestProp prop : props) {
JLabel label = prop.getLabel();
gbConst.gridwidth = 1;
inputPanel.add(label, gbConst);
inputPanel.add(Box.createHorizontalStrut(5));
JComponent comp = prop.getValueComponent();
gbConst.gridwidth = GridBagConstraints.REMAINDER;
inputPanel.add(comp, gbConst);
if (prop.isRequired) hasRequiredFields = true;
}
if (hasRequiredFields) {
inputPanel.add(new JLabel(" * = Required Field"));
}
return new JScrollPane(inputPanel);
}
@Override
public Component createPageComponent() {
GridBagConstraints gbc = new GridBagConstraints();
final JPanel panel = new JPanel(new GridBagLayout());
gbc.anchor = GridBagConstraints.WEST;
gbc.gridy = 0;
gbc.gridx = 0;
gbc.gridy++;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridwidth = 2;
panel.add(new JLabel("URL for WMS (e.g. http://<host>/<server>):"), gbc);
gbc.weightx = 1;
gbc.weighty = 0;
gbc.gridx = 0;
gbc.gridy++;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridwidth = 1;
history = new UserInputHistory(8, PROPERTY_WMS_HISTORY);
history.initBy(SnapApp.getDefault().getPreferences());
if (history.getNumEntries() == 0) {
history.push("http://geoservice.dlr.de/basemap/wms");
history.push("https://www.geoseaportal.de/wss/service/StaticInformation_Background/guest");
}
wmsUrlBox = new JComboBox(new HistoryComboBoxModel(history));
wmsUrlBox.setEditable(true);
panel.add(wmsUrlBox, gbc);
wmsUrlBox.addItemListener(new MyItemListener());
return panel;
}
/**
* Creates an <code>AbstractSearchDialog</code>.
*
* @param comp
* only used to identify the frame to bind this dialog to.
*/
public AbstractSearchDialog(JComponent comp) {
super(getFrame(comp), strings.getString("dialogTitle"));
Color fg = UIManager.getColor("Label.disabledForeground");
if (fg != null) {
notFound.setForeground(fg);
}
JPanel notFoundContainer = new JPanel();
notFoundContainer.add(notFound);
Dimension preferredSize = notFoundContainer.getPreferredSize();
notFoundContainer.setPreferredSize(preferredSize);
notFoundContainer.setMinimumSize(preferredSize);
notFound.setVisible(false);
nextButton.setToolTipText(strings.getString("nextTip"));
prevButton.setToolTipText(strings.getString("previousTip"));
DialogFooter footer = new DialogFooter(
new JComponent[] { notFoundContainer }, new JComponent[] {
nextButton, prevButton }, false, nextButton);
setFooter(footer);
JPanel content = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.EAST;
c.insets = new Insets(3, 3, 3, 3);
c.weightx = 0;
c.weighty = 0;
content.add(findLabel, c);
c.anchor = GridBagConstraints.WEST;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx++;
content.add(textField, c);
setContent(content);
nextButton.addActionListener(actionListener);
prevButton.addActionListener(actionListener);
setModal(false);
setCloseable(true);
pack();
}
private JPanel buildHeaderPanel()
{
JPanel contentPanel = new JPanel();
contentPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
contentPanel.add(methodLabel,
new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(0, 0, 0, 0), 0, 0));
contentPanel.add(methodList,
new GridBagConstraints(1, 0, 4, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(0, 5, 5, 0), 0, 0));
contentPanel.add(newResourceButton,
new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(0, 5, 5, 0), 0, 0));
methodList.addActionListener(this);
newResourceButton.setToolTipText("New Custom Resource");
gbc.gridwidth = 6;
gbc.gridheight = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.NONE;
gbc.gridx=0;
gbc.gridy=1;
gbc.weightx = 0;
gbc.gridwidth = 3;
restSpecificPanel.setLayout(new GridBagLayout());
contentPanel.add(restSpecificPanel,
new GridBagConstraints(0, 1, 6, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(0, 0, 0, 0), 0, 0));
// GridBagConstraints gbcRest = new GridBagConstraints();
// gbcRest.insets = new Insets(0, 0, 5, 5);
// gbcRest.gridx = 0;
// gbcRest.gridy = 0;
// gbcRest.gridwidth = 2;
// gbcRest.gridheight = 1;
// gbcRest.anchor = GridBagConstraints.WEST;
// gbcRest.fill = GridBagConstraints.NONE;
restSpecificPanel.add(sendSerializedDO,
new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(0, 0, 5, 5), 0, 0));
sendSerializedDO.addActionListener(this);
addButton.addActionListener(this);
removeButton.addActionListener(this);
removeButton.setEnabled(false);
restSpecificPanel.add(sendAsArray,
new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(0, 0, 5, 5), 0, 0));
sendAsArray.addActionListener(this);
restSpecificPanel.add(deleteLocalRows,
new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(0, 0, 5, 5), 0, 0));
deleteLocalRows.addActionListener(this);
restSpecificPanel.add(payloadListElementLabel,
new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(0, 0, 5, 5), 0, 0));
restSpecificPanel.add(payloadListElementField,
new GridBagConstraints(1, 3, 4, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 5, 5), 0, 0));
restSpecificPanel.add(payloadRowElementLabel,
new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(0, 0, 5, 5), 0, 0));
restSpecificPanel.add(payloadRowElementField,
new GridBagConstraints(1, 4, 4, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 5, 5), 0, 0));
restSpecificPanel.add(attrsToExcludeLabel,
new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(0, 0, 5, 5), 0, 0));
restSpecificPanel.add(attrsToExclude,
new GridBagConstraints(1, 5, 4, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 5, 5), 0, 0));
restSpecificPanel.add(new JLabel("Parameters"),
new GridBagConstraints(0, 6, 5, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(0, 0, 5, 5), 0, 0));
restSpecificPanel.add(addButton,
new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
new Insets(0, 0, 5, 5), 0, 0));
restSpecificPanel.add(removeButton,
new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
new Insets(0, 0, 5, 5), 0, 0));
restSpecificPanel.add(setHeadersButton,
new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
new Insets(0, 0, 5, 5), 0, 0));
return contentPanel;
}
private void initComponents() {
endmemberList = new JList<>();
endmemberList.setModel(formModel.getEndmemberListModel());
endmemberList.setSelectionModel(formModel.getEndmemberListSelectionModel());
endmemberList.setPreferredSize(new Dimension(80, 160));
diagramCanvas = new DiagramCanvas();
diagramCanvas.setDiagram(formModel.getEndmemberDiagram());
formModel.getPropertyChangeSupport().addPropertyChangeListener("selectedEndmemberIndex",
evt -> diagramCanvas.repaint());
AbstractButton addButton = ToolButtonFactory.createButton(formModel.getAddAction(), false);
AbstractButton removeButton = ToolButtonFactory.createButton(formModel.getRemoveAction(), false);
AbstractButton clearButton = ToolButtonFactory.createButton(formModel.getClearAction(), false);
AbstractButton exportButton = ToolButtonFactory.createButton(formModel.getExportAction(), false);
GridBagLayout gbl = new GridBagLayout();
JPanel actionPanel = new JPanel(gbl);
actionPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 0, 3));
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
gbc.ipady = 2;
gbc.gridy = 0;
actionPanel.add(addButton, gbc);
gbc.gridy++;
actionPanel.add(removeButton, gbc);
gbc.gridy++;
actionPanel.add(clearButton, gbc);
gbc.gridy++;
actionPanel.add(exportButton, gbc);
gbc.gridy++;
gbc.weighty = 1;
actionPanel.add(new JLabel(), gbc);
final Color color = actionPanel.getBackground();
final float[] rgbColors = new float[3];
color.getRGBColorComponents(rgbColors);
final float factor = 0.9f;
actionPanel.setBackground(new Color(rgbColors[0] * factor, rgbColors[1] * factor, rgbColors[2] * factor));
JPanel endmemberSelectionPanel = new JPanel(new BorderLayout());
endmemberSelectionPanel.add(new JScrollPane(endmemberList), BorderLayout.CENTER);
endmemberSelectionPanel.add(actionPanel, BorderLayout.WEST);
JPanel endmemberPreviewPanel = new JPanel(new BorderLayout());
endmemberPreviewPanel.add(diagramCanvas, BorderLayout.CENTER);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setLeftComponent(endmemberSelectionPanel);
splitPane.setRightComponent(endmemberPreviewPanel);
splitPane.setBorder(BorderFactory.createEmptyBorder());
splitPane.setUI(createPlainDividerSplitPaneUI());
setLayout(new BorderLayout());
add(splitPane, BorderLayout.CENTER);
}
/**
* Creates a connection information display panel.
*
* @param connection
* the model of the connection to show
* @param showDescriptions
* if {@code true} descriptions for the headers are displayed
*/
public ConnectionInfoPanel(ConnectionModel connection, boolean showDescriptions) {
super(new GridBagLayout());
this.editable = connection.isEditable();
String connectionType = connection.getType();
isTypeKnown = ConnectionHandlerRegistry.getInstance().isTypeKnown(connectionType);
// header with icon, name, and type
GridBagConstraints gbc = new GridBagConstraints();
JPanel headerPanel = new JPanel(new GridBagLayout());
GridBagConstraints headerGbc = new GridBagConstraints();
headerGbc.gridx = 0;
headerGbc.gridy = 0;
headerGbc.anchor = GridBagConstraints.WEST;
headerGbc.gridheight = 2;
headerGbc.insets = new Insets(0, 0, 0, 10);
headerPanel.add(new JLabel(ConnectionI18N.getConnectionIcon(connectionType, IconSize.HUGE)), headerGbc);
headerGbc.gridx = 1;
headerGbc.gridheight = 1;
headerGbc.insets = new Insets(0, 0, 0, 0);
JLabel nameLabel = new JLabel(connection.getName());
nameLabel.setToolTipText(connection.getName());
nameLabel.setFont(OPEN_SANS_SEMIBOLD_24);
headerPanel.add(nameLabel, headerGbc);
headerGbc.gridx = 1;
headerGbc.gridy += 1;
headerGbc.gridheight = 1;
JComponent typeComponent = createTypeComponent(connectionType);
headerPanel.add(typeComponent, headerGbc);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.insets = new Insets(25, 25, 15, 25);
JPanel headerOuterPanel = new JPanel(new BorderLayout());
headerOuterPanel.add(headerPanel, BorderLayout.WEST);
add(headerOuterPanel, gbc);
gbc.gridy += 1;
gbc.weightx = 0.8;
gbc.insets = new Insets(0, 20, 0, 200);
JSeparator separator = new JSeparator();
add(separator, gbc);
// body with location, description, and tags
JPanel bodyPanel = new JPanel(new GridLayout(3, 2, 30, 20));
bodyPanel.add(createDescriptionPanel(ConnectionI18N.getConnectionGUILabel("location"),
ConnectionI18N.getConnectionGUILabel("location_description"), showDescriptions));
String repositoryName = connection.getLocation() != null ?
RepositoryLocation.REPOSITORY_PREFIX + connection.getLocation().getRepositoryName() : "";
JTextArea locArea = new JTextArea(repositoryName);
locArea.setEditable(false);
locArea.setHighlighter(null);
locArea.setLineWrap(true);
locArea.setComponentPopupMenu(null);
locArea.setInheritsPopupMenu(false);
locArea.setBackground(getBackground());
locArea.setBorder(BorderFactory.createEmptyBorder());
locArea.setFont(OPEN_SANS_12);
if (!isTypeKnown) {
locArea.setForeground(UNKNOWN_TYPE_COLOR);
}
bodyPanel.add(locArea);
bodyPanel.add(createDescriptionPanel(ConnectionI18N.getConnectionGUILabel("description"),
ConnectionI18N.getConnectionGUILabel("description_description"), showDescriptions));
bodyPanel.add(createTextArea(connection.descriptionProperty()));
bodyPanel.add(createDescriptionPanel(ConnectionI18N.getConnectionGUILabel("tags"),
ConnectionI18N.getConnectionGUILabel("tags_description"), showDescriptions));
bodyPanel.add(createTagPanel(connection.getTags(), connection::setTags));
gbc.gridy += 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(15, 25, 10, 25);
add(bodyPanel, gbc);
}
private void layoutComponents() {
final Container content = getContentPane();
content.setLayout(new BorderLayout());
final JPanel title = new JPanel();
title.add(new JLabel("Select client options"));
content.add(title, BorderLayout.NORTH);
final Insets labelSpacing = new Insets(3, 7, 0, 0);
final Insets fieldSpacing = new Insets(3, 5, 0, 7);
final GridBagConstraints labelConstraints = new GridBagConstraints();
labelConstraints.anchor = GridBagConstraints.EAST;
labelConstraints.gridx = 0;
labelConstraints.insets = labelSpacing;
final GridBagConstraints fieldConstraints = new GridBagConstraints();
fieldConstraints.anchor = GridBagConstraints.WEST;
fieldConstraints.gridx = 1;
fieldConstraints.insets = fieldSpacing;
final JPanel fields = new JPanel();
final GridBagLayout layout = new GridBagLayout();
fields.setLayout(layout);
final JLabel nameLabel = new JLabel("Name:");
final JLabel portLabel = new JLabel("Server Port:");
final JLabel addressLabel = new JLabel("Server Address:");
layout.setConstraints(portLabel, labelConstraints);
layout.setConstraints(nameLabel, labelConstraints);
layout.setConstraints(addressLabel, labelConstraints);
layout.setConstraints(portField, fieldConstraints);
layout.setConstraints(nameField, fieldConstraints);
layout.setConstraints(addressField, fieldConstraints);
fields.add(nameLabel);
fields.add(nameField);
fields.add(portLabel);
fields.add(portField);
fields.add(addressLabel);
fields.add(addressField);
content.add(fields, BorderLayout.CENTER);
final JPanel buttons = new JPanel();
buttons.add(
new JButton(
SwingAction.of(
"Connect",
e -> {
setVisible(false);
okPressed = true;
})));
buttons.add(new JButton(SwingAction.of("Cancel", e -> setVisible(false))));
content.add(buttons, BorderLayout.SOUTH);
}
private void init() {
setLayout(new BorderLayout());
JPanel container = this;
mBuckPathField = new TextFieldWithBrowseButton();
FileChooserDescriptor fileChooserDescriptor =
new FileChooserDescriptor(true, false, false, false, false, false);
mBuckPathField.addBrowseFolderListener(
"",
"Buck Executable Path",
null,
fileChooserDescriptor,
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT,
false
);
mCustomizedInstallSettingField = new JBTextField();
mCustomizedInstallSettingField.getEmptyText().setText(CUSTOMIZED_INSTALL_COMMAND_HINT);
mCustomizedInstallSettingField.setEnabled(false);
mRunAfterInstall = new JCheckBox("Run after install (-r)");
mMultiInstallMode = new JCheckBox("Multi-install mode (-x)");
mUninstallBeforeInstall = new JCheckBox("Uninstall before installing (-u)");
mCustomizedInstallSetting = new JCheckBox("Use customized install setting: ");
initCustomizedInstallCommandListener();
JPanel buckSettings = new JPanel(new GridBagLayout());
buckSettings.setBorder(IdeBorderFactory.createTitledBorder("Buck Settings", true));
container.add(container = new JPanel(new BorderLayout()), BorderLayout.NORTH);
container.add(buckSettings, BorderLayout.NORTH);
final GridBagConstraints constraints = new GridBagConstraints(0, 0, 1, 1, 0, 0,
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
buckSettings.add(new JLabel("Buck Executable Path:"), constraints);
constraints.gridx = 1;
constraints.weightx = 1;
constraints.fill = GridBagConstraints.HORIZONTAL;
buckSettings.add(mBuckPathField, constraints);
JPanel installSettings = new JPanel(new BorderLayout());
installSettings.setBorder(IdeBorderFactory.createTitledBorder("Buck Install Settings", true));
container.add(container = new JPanel(new BorderLayout()), BorderLayout.SOUTH);
container.add(installSettings, BorderLayout.NORTH);
installSettings.add(mRunAfterInstall, BorderLayout.NORTH);
installSettings.add(installSettings = new JPanel(new BorderLayout()), BorderLayout.SOUTH);
installSettings.add(mMultiInstallMode, BorderLayout.NORTH);
installSettings.add(installSettings = new JPanel(new BorderLayout()), BorderLayout.SOUTH);
installSettings.add(mUninstallBeforeInstall, BorderLayout.NORTH);
installSettings.add(installSettings = new JPanel(new BorderLayout()), BorderLayout.SOUTH);
final GridBagConstraints customConstraints = new GridBagConstraints(0, 0, 1, 1, 0, 0,
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
JPanel customizedInstallSetting = new JPanel(new GridBagLayout());
customizedInstallSetting.add(mCustomizedInstallSetting, customConstraints);
customConstraints.gridx = 1;
customConstraints.weightx = 1;
customConstraints.fill = GridBagConstraints.HORIZONTAL;
customizedInstallSetting.add(mCustomizedInstallSettingField, customConstraints);
installSettings.add(customizedInstallSetting, BorderLayout.NORTH);
}
private JPanel createAppearancePanel()
{
JPanel pnl = new JPanel(new GridBagLayout());
// i18n[generalSessionPropertiesPanel.appearance=Appearance]
pnl.setBorder(BorderFactory.createTitledBorder(s_stringMgr.getString("generalSessionPropertiesPanel.appearance")));
final GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets(4, 4, 4, 4);
gbc.gridx = 0;
gbc.gridy = 0;
pnl.add(_showToolBar, gbc);
++gbc.gridy;
pnl.add(new JLabel(GeneralSessionPropertiesPanelI18n.MAIN_TAB_PLACEMENT, SwingConstants.RIGHT), gbc);
++gbc.gridx;
gbc.weightx = 0.5;
pnl.add(_mainTabPlacementCmb, gbc);
++gbc.gridx;
gbc.weightx = 0.0;
pnl.add(new JLabel(GeneralSessionPropertiesPanelI18n.OBJECT_TAB_PLACEMENT, SwingConstants.RIGHT), gbc);
++gbc.gridx;
gbc.weightx = 0.5;
pnl.add(_objectTabPlacementCmb, gbc);
gbc.gridx = 0;
++gbc.gridy;
pnl.add(new JLabel(GeneralSessionPropertiesPanelI18n.SQL_EXECUTION_TAB_PLACEMENT, SwingConstants.RIGHT), gbc);
++gbc.gridx;
gbc.weightx = 0.5;
pnl.add(_sqlExecutionTabPlacementCmb, gbc);
++gbc.gridx;
gbc.weightx = 0.0;
pnl.add(new JLabel(GeneralSessionPropertiesPanelI18n.SQL_RESULTS_TAB_PLACEMENT, SwingConstants.RIGHT), gbc);
++gbc.gridx;
gbc.weightx = 0.5;
pnl.add(_sqlResultsTabPlacementCmb, gbc);
gbc.gridx = 0;
++gbc.gridy;
pnl.add(new JLabel(GeneralSessionPropertiesPanelI18n.SQL_PANEL_ORIENTATION, SwingConstants.RIGHT), gbc);
++gbc.gridx;
gbc.weightx = 0.5;
gbc.gridwidth=3;
pnl.add(_splitPaneOrientationCmb, gbc);
return pnl;
}
/**
* Build the user interface ready for display.
*/
private void initComponents()
{
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets(2, 2, 2, 2);
GridBagLayout gridbag = new GridBagLayout();
setTitle(TITLE);
setLayout(gridbag);
// Data set selection row
Utility.buildConstraints(gbc, 0, 0, 1, 1, 0.0, 0.0);
JLabel dataSetLabel = new JLabel(LanguageBundle.getString("in_diDataSet"), SwingConstants.RIGHT);
gridbag.setConstraints(dataSetLabel, gbc);
add(dataSetLabel, gbc);
Utility.buildConstraints(gbc, 1, 0, 2, 1, 1.0, 0.0);
dataSetSel = new JTextField("", SwingConstants.WEST);
dataSetSel.setEditable(false);
gridbag.setConstraints(dataSetSel, gbc);
add(dataSetSel, gbc);
Utility.buildConstraints(gbc, 3, 0, 1, 1, 0.0, 0.0);
gbc.fill = GridBagConstraints.NONE;
selectButton = new JButton();
CommonMenuText.name(selectButton, "select"); //$NON-NLS-1$
gridbag.setConstraints(selectButton, gbc);
add(selectButton, gbc);
selectButton.addActionListener(listener);
// Data set details row
Utility.buildConstraints(gbc, 0, 1, 4, 1, 1.0, 1.0);
dataSetDetails = new JFXPanelFromResource<>(
SimpleHtmlPanelController.class,
"SimpleHtmlPanel.fxml"
);
dataSetDetails.setPreferredSize(new Dimension(400, 200));
dataSetDetails.setBackground(getBackground());
gbc.fill = GridBagConstraints.BOTH;
JScrollPane jScrollPane = new JScrollPane();
jScrollPane.setViewportView(dataSetDetails);
gridbag.setConstraints(jScrollPane, gbc);
add(jScrollPane, gbc);
// Location row
Utility.buildConstraints(gbc, 0, 2, 1, 1, 0.0, 0.0);
gbc.fill = GridBagConstraints.HORIZONTAL;
JLabel locLabel = new JLabel(LanguageBundle.getString("in_diLocation"), SwingConstants.RIGHT);
gridbag.setConstraints(locLabel, gbc);
add(locLabel, gbc);
ButtonGroup exclusiveGroup = new ButtonGroup();
locDataButton = new JRadioButton(LanguageBundle.getString("in_diData"));
locDataButton.setToolTipText(LanguageBundle.getString("in_diData_tip"));
exclusiveGroup.add(locDataButton);
locVendorDataButton = new JRadioButton(LanguageBundle.getString("in_diVendorData"));
locVendorDataButton.setToolTipText(LanguageBundle.getString("in_diVendorData_tip"));
exclusiveGroup.add(locVendorDataButton);
locHomebrewDataButton = new JRadioButton(LanguageBundle.getString("in_diHomebrewData"));
locHomebrewDataButton.setToolTipText(LanguageBundle.getString("in_diHomebrewData_tip"));
exclusiveGroup.add(locHomebrewDataButton);
JPanel optionsPanel = new JPanel();
optionsPanel.add(locDataButton);
optionsPanel.add(locVendorDataButton);
optionsPanel.add(locHomebrewDataButton);
Utility.buildConstraints(gbc, 1, 2, 3, 1, 0.0, 0.0);
gridbag.setConstraints(optionsPanel, gbc);
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
add(optionsPanel, gbc);
// Buttons row
installButton = new JButton();
CommonMenuText.name(installButton, "diInstall"); //$NON-NLS-1$
installButton.addActionListener(listener);
closeButton = new JButton();
CommonMenuText.name(closeButton, "close"); //$NON-NLS-1$
closeButton.addActionListener(listener);
JPanel buttonsPanel = new JPanel();
buttonsPanel.add(installButton);
buttonsPanel.add(closeButton);
Utility.buildConstraints(gbc, 2, 3, 2, 1, 0.0, 0.0);
gridbag.setConstraints(buttonsPanel, gbc);
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.EAST;
add(buttonsPanel, gbc);
pack();
}