本文整理汇总了Java中java.awt.GridBagLayout.setConstraints方法的典型用法代码示例。如果您正苦于以下问题:Java GridBagLayout.setConstraints方法的具体用法?Java GridBagLayout.setConstraints怎么用?Java GridBagLayout.setConstraints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.GridBagLayout
的用法示例。
在下文中一共展示了GridBagLayout.setConstraints方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRow
import java.awt.GridBagLayout; //导入方法依赖的package包/类
private void addRow(GridBagLayout gb, GridBagConstraints gc, JLabel label, JComboBox<?> choice) {
Insets oldInsets = gc.insets;
gc.weightx = 0.0;
gc.gridx = 0;
gc.fill = GridBagConstraints.HORIZONTAL;
gc.anchor = GridBagConstraints.LINE_START;
gc.insets = new Insets(5, 5, 5, 5);
gb.setConstraints(label, gc);
add(label);
gc.gridx = 1;
gc.fill = GridBagConstraints.VERTICAL;
gb.setConstraints(choice, gc);
add(choice);
gc.gridy++;
gc.insets = oldInsets;
}
示例2: initComponents
import java.awt.GridBagLayout; //导入方法依赖的package包/类
/** Inits the subcomponents. Sets layout for this top component and adds {@code BundleEditPanel} to it.
* @see BundleEditPanel */
private void initComponents() {
GridBagLayout gridbag = new GridBagLayout();
setLayout(gridbag);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1.0;
c.weighty = 1.0;
c.gridwidth = GridBagConstraints.REMAINDER;
JPanel panel = new BundleEditPanel(bundleStructure, new PropertiesTableModel(bundleStructure));
gridbag.setConstraints(panel, c);
add(panel);
}
示例3: getPlotter
import java.awt.GridBagLayout; //导入方法依赖的package包/类
/**
* Returns this. Subclasses which do not want to use this object (JPanel) for plotting should
* directly implement {@link Plotter}.
*/
@Override
public JComponent getPlotter() {
if (this.plotpanel == null) {
this.plotpanel = createPlotPanel();
if (hasLegend()) {
this.plotpanel.addLegend(LEGEND_POSITION);
}
GridBagLayout layout = new GridBagLayout();
this.setLayout(layout);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1;
if (hasRapidMinerValueLegend()) {
legend = new PlotterLegend(this);
c.weighty = 0;
JPanel legendPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
legendPanel.setBackground(Color.white);
legendPanel.add(legend);
layout.setConstraints(legendPanel, c);
add(legendPanel);
}
c.weighty = 1;
layout.setConstraints(plotpanel, c);
add(plotpanel);
}
return this;
}
示例4: addNameDefinitionStep
import java.awt.GridBagLayout; //导入方法依赖的package包/类
private void addNameDefinitionStep() {
JPanel panel = SwingTools.createTextPanel("Please specify the column names...",
"Please specify if the names can be taken from the first line of the data file.");
GridBagLayout layout = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 0;
c.weighty = 0;
c.insets = new Insets(7, 7, 7, 7);
JPanel content = new JPanel(layout);
firstRowAsNames.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
reloadData();
updateViews();
}
});
c.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(firstRowAsNames, c);
content.add(firstRowAsNames);
panel.add(content, BorderLayout.CENTER);
addStep(panel);
}
示例5: addToGB
import java.awt.GridBagLayout; //导入方法依赖的package包/类
/**
* Sets the constraints for the GridBagLayout and adds the Component
* to the given Container
*/
private static void addToGB(Component comp, Container cont,
GridBagLayout gridbag,
GridBagConstraints constraints)
{
gridbag.setConstraints(comp, constraints);
cont.add(comp);
}
示例6: addComponent
import java.awt.GridBagLayout; //导入方法依赖的package包/类
private void addComponent(Component component, GridBagLayout gbl, GridBagConstraints gbc, int row, int column, int width, int heigth) {
Container c = this.getContentPane();
gbc.gridx = column;
gbc.gridy = row;
gbc.gridwidth = width;
gbc.gridheight = heigth;
gbl.setConstraints(component, gbc);
c.add(component);
}
示例7: addNewComponent
import java.awt.GridBagLayout; //导入方法依赖的package包/类
/**
* Add a component to the PolicyTool window
*/
void addNewComponent(Container container, JComponent component,
int index, int gridx, int gridy, int gridwidth, int gridheight,
double weightx, double weighty, int fill, Insets is) {
if (container instanceof JFrame) {
container = ((JFrame)container).getContentPane();
} else if (container instanceof JDialog) {
container = ((JDialog)container).getContentPane();
}
// add the component at the specified gridbag index
container.add(component, index);
// set the constraints
GridBagLayout gbl = (GridBagLayout)container.getLayout();
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = gridx;
gbc.gridy = gridy;
gbc.gridwidth = gridwidth;
gbc.gridheight = gridheight;
gbc.weightx = weightx;
gbc.weighty = weighty;
gbc.fill = fill;
if (is != null) gbc.insets = is;
gbl.setConstraints(component, gbc);
}
示例8: StereoMatchingFrame
import java.awt.GridBagLayout; //导入方法依赖的package包/类
/** Creates new form StereoMatchingViewer */
public StereoMatchingFrame(AEChip chip, int maxDisp) {
this.chip = chip;
this.maxDisp = maxDisp;
initComponents();
GridBagLayout layout = new GridBagLayout();
GridBagConstraints layoutConstraints = new GridBagConstraints();
layoutConstraints.anchor = GridBagConstraints.NORTHWEST;
layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
setLayout(layout);
labelDisp = new Label("Disparity: " + 0);
layout.setConstraints(labelDisp, layoutConstraints);
add(labelDisp);
labelSmc = new Label("Matching matrix");
layout.setConstraints(labelSmc, layoutConstraints);
add(labelSmc);
smc = new StereoMatchingCanvas(chip);
layout.setConstraints(smc, layoutConstraints);
add(smc);
labelScd = new Label("Accumulated disparity values");
layout.setConstraints(labelScd, layoutConstraints);
add(labelScd);
sdc = new StereoDisparitiesCanvas(maxDisp);
layout.setConstraints(sdc, layoutConstraints);
add(sdc);
setPreferredSize(null);
pack();
}
示例9: ExpressionTab
import java.awt.GridBagLayout; //导入方法依赖的package包/类
public ExpressionTab(AnalyzerModel model) {
this.model = model;
selector = new OutputSelector(model);
model.getOutputExpressions().addOutputExpressionsListener(myListener);
selector.addItemListener(myListener);
clear.addActionListener(myListener);
revert.addActionListener(myListener);
enter.addActionListener(myListener);
field.setLineWrap(true);
field.setWrapStyleWord(true);
field.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), myListener);
field.getDocument().addDocumentListener(myListener);
field.setFont(new Font("sans serif", Font.PLAIN, 14));
JPanel buttons = new JPanel();
buttons.add(clear);
buttons.add(revert);
buttons.add(enter);
GridBagLayout gb = new GridBagLayout();
GridBagConstraints gc = new GridBagConstraints();
setLayout(gb);
gc.weightx = 1.0;
gc.gridx = 0;
gc.gridy = GridBagConstraints.RELATIVE;
gc.fill = GridBagConstraints.BOTH;
JPanel selectorPanel = selector.createPanel();
gb.setConstraints(selectorPanel, gc);
add(selectorPanel);
gb.setConstraints(prettyView, gc);
add(prettyView);
gc.insets = new Insets(10, 10, 0, 10);
JScrollPane fieldPane = new JScrollPane(field, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
gb.setConstraints(fieldPane, gc);
add(fieldPane);
gb.setConstraints(buttons, gc);
add(buttons);
gc.fill = GridBagConstraints.BOTH;
gb.setConstraints(error, gc);
add(error);
myListener.insertUpdate(null);
setError(null);
}
示例10: OperatorPanel
import java.awt.GridBagLayout; //导入方法依赖的package包/类
public OperatorPanel() {
setBackground(new java.awt.Color(0, 0, 0, 0));
setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
GridBagConstraints c = new GridBagConstraints();
c.anchor = GridBagConstraints.LINE_START;
c.fill = GridBagConstraints.NONE;
c.weightx = 0;
layout.setConstraints(iconLabel, c);
add(iconLabel);
// name panel
JPanel namePanel = new JPanel();
namePanel.setBackground(new java.awt.Color(0, 0, 0, 0));
GridBagLayout nameLayout = new GridBagLayout();
GridBagConstraints nameC = new GridBagConstraints();
nameC.fill = GridBagConstraints.BOTH;
nameC.insets = new Insets(0, 5, 0, 5);
namePanel.setLayout(nameLayout);
nameLabel.setHorizontalAlignment(SwingConstants.LEFT);
nameLabel.setFont(getFont().deriveFont(Font.PLAIN, 12));
nameC.gridwidth = GridBagConstraints.REMAINDER;
nameLayout.setConstraints(nameLabel, nameC);
namePanel.add(nameLabel);
classLabel.setHorizontalAlignment(SwingConstants.LEFT);
classLabel.setFont(getFont().deriveFont(Font.PLAIN, 10));
nameLayout.setConstraints(classLabel, nameC);
namePanel.add(classLabel);
c.weightx = 1;
add(namePanel, c);
c.gridwidth = GridBagConstraints.RELATIVE;
c.weightx = 0;
layout.setConstraints(breakpoint, c);
add(breakpoint);
c.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(error, c);
add(error);
}
示例11: DistributionModelPlotVisualizer
import java.awt.GridBagLayout; //导入方法依赖的package包/类
public DistributionModelPlotVisualizer(DistributionModel distributionModel) {
super(distributionModel, "plot_view");
setLayout(new BorderLayout());
DataTable table = new SimpleDataTable("Dummy", distributionModel.getAttributeNames());
final PlotterConfigurationModel settings = new PlotterConfigurationModel(
PlotterConfigurationModel.COMPLETE_PLOTTER_SELECTION, table);
final Plotter plotter = new DistributionPlotter(settings, distributionModel);
settings.setPlotter(plotter);
plotterComponent = plotter.getPlotter();
plotterComponent.setBorder(BorderFactory.createMatteBorder(15, 0, 10, 5, Colors.WHITE));
add(plotterComponent, BorderLayout.CENTER);
final ListeningJComboBox combo = new ListeningJComboBox(settings, PlotterAdapter.PARAMETER_PLOT_COLUMN + "_"
+ PlotterAdapter.transformParameterName(plotter.getPlotName()), distributionModel.getAttributeNames());
combo.setPreferredSize(new Dimension(200, PropertyPanel.VALUE_CELL_EDITOR_HEIGHT));
combo.putClientProperty(RapidLookTools.PROPERTY_INPUT_BACKGROUND_DARK, true);
GridBagLayout layout = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weighty = 0.0d;
c.weightx = 1.0d;
c.insets = new Insets(4, 4, 4, 4);
c.gridwidth = GridBagConstraints.REMAINDER;
JPanel boxPanel = new JPanel(layout);
boxPanel.setBorder(BorderFactory.createMatteBorder(10, 8, 5, 10, Colors.WHITE));
boxPanel.setOpaque(true);
boxPanel.setBackground(Colors.WHITE);
JLabel label = new JLabel("Attribute:");
layout.setConstraints(label, c);
boxPanel.add(label);
layout.setConstraints(combo, c);
boxPanel.add(combo);
final JCheckBox rotateLabels = new JCheckBox("Rotate Labels", false);
layout.setConstraints(rotateLabels, c);
boxPanel.add(rotateLabels);
c.weighty = 1.0;
JLabel filler = new JLabel();
layout.setConstraints(filler, c);
boxPanel.add(filler);
add(boxPanel, BorderLayout.WEST);
combo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
settings.setParameterAsString(PlotterAdapter.PARAMETER_PLOT_COLUMN, combo.getSelectedItem().toString());
}
});
rotateLabels.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
settings.setParameterAsBoolean(LabelRotatingPlotterAdapter.PARAMETER_ROTATE_LABELS,
rotateLabels.isSelected());
}
});
combo.setSelectedIndex(0);
}
示例12: setupPanel
import java.awt.GridBagLayout; //导入方法依赖的package包/类
private void setupPanel() {
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1;
gbc.insets = new Insets( 2, 0, 2, 2 );
this.setLayout( gbl );
addLabeledComponentToGBL( "Font: ", fontMenu, gbl, gbc, this );
addLabeledComponentToGBL( "Size: ", sizeField, gbl, gbc, this );
gbc.gridwidth = GridBagConstraints.REMAINDER;
addLabeledComponentToGBL( "Font Transform:",
transformMenu, gbl, gbc, this );
gbc.gridwidth = 1;
addLabeledComponentToGBL( "Range: ", rm, gbl, gbc, this );
addLabeledComponentToGBL( "Style: ", styleMenu, gbl, gbc, this );
gbc.gridwidth = GridBagConstraints.REMAINDER;
addLabeledComponentToGBL( "Graphics Transform: ",
transformMenuG2, gbl, gbc, this );
gbc.gridwidth = 1;
gbc.anchor = GridBagConstraints.WEST;
addLabeledComponentToGBL( "Method: ", methodsMenu, gbl, gbc, this );
addLabeledComponentToGBL("", null, gbl, gbc, this);
gbc.anchor = GridBagConstraints.EAST;
gbc.gridwidth = GridBagConstraints.REMAINDER;
addLabeledComponentToGBL( "Text to use:", textMenu, gbl, gbc, this );
gbc.weightx=1;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.WEST;
addLabeledComponentToGBL("LCD contrast: ",
contrastSlider, gbl, gbc, this);
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.NONE;
addLabeledComponentToGBL("Antialiasing: ",
antiAliasMenu, gbl, gbc, this);
gbc.anchor = GridBagConstraints.EAST;
gbc.gridwidth = GridBagConstraints.REMAINDER;
addLabeledComponentToGBL("Fractional metrics: ",
fracMetricsMenu, gbl, gbc, this);
gbc.weightx = 1;
gbc.weighty = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets( 2, 0, 0, 2 );
gbc.fill = GridBagConstraints.BOTH;
gbl.setConstraints( fp, gbc );
this.add( fp );
gbc.weighty = 0;
gbc.insets = new Insets( 0, 2, 0, 0 );
gbl.setConstraints( statusBar, gbc );
this.add( statusBar );
}
示例13: SelectionPanel
import java.awt.GridBagLayout; //导入方法依赖的package包/类
public SelectionPanel(LogFrame window) {
super(window);
selector = new ComponentSelector(getModel());
addTool = new JButton();
changeBase = new JButton();
moveUp = new JButton();
moveDown = new JButton();
remove = new JButton();
removeAll = new JButton();
clearComponentLog = new JButton();
list = new SelectionList();
list.setSelection(getSelection());
JPanel buttons = new JPanel(new GridLayout(7, 1));
buttons.add(addTool);
buttons.add(changeBase);
buttons.add(moveUp);
buttons.add(moveDown);
buttons.add(remove);
buttons.add(removeAll);
buttons.add(clearComponentLog);
addTool.addActionListener(listener);
changeBase.addActionListener(listener);
moveUp.addActionListener(listener);
moveDown.addActionListener(listener);
remove.addActionListener(listener);
removeAll.addActionListener(listener);
clearComponentLog.addActionListener(listener);
selector.addMouseListener(listener);
selector.addTreeSelectionListener(listener);
list.addListSelectionListener(listener);
listener.computeEnabled();
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
setLayout(gridbag);
JScrollPane explorerPane = new JScrollPane(selector, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JScrollPane listPane = new JScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gridbag.setConstraints(explorerPane, gbc);
add(explorerPane);
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.NORTH;
gbc.weightx = 0.0;
gridbag.setConstraints(buttons, gbc);
add(buttons);
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1.0;
gridbag.setConstraints(listPane, gbc);
add(listPane);
}
示例14: MinimizedTab
import java.awt.GridBagLayout; //导入方法依赖的package包/类
public MinimizedTab(AnalyzerModel model) {
this.outputExprs = model.getOutputExpressions();
outputExprs.addOutputExpressionsListener(myListener);
selector = new OutputSelector(model);
selector.addItemListener(myListener);
karnaughMap = new KarnaughMapPanel(model);
karnaughMap.addMouseListener(new TruthTableMouseListener());
setAsExpr.addActionListener(myListener);
formatChoice.addItemListener(myListener);
JPanel buttons = new JPanel(new GridLayout(1, 1));
buttons.add(setAsExpr);
JPanel formatPanel = new JPanel();
formatPanel.add(formatLabel);
formatPanel.add(formatChoice);
GridBagLayout gb = new GridBagLayout();
GridBagConstraints gc = new GridBagConstraints();
setLayout(gb);
gc.gridx = 0;
gc.gridy = 0;
addRow(gb, gc, selector.getLabel(), selector.getComboBox());
addRow(gb, gc, formatLabel, formatChoice);
gc.weightx = 0.0;
gc.gridx = 0;
gc.gridwidth = 2;
gc.gridy = GridBagConstraints.RELATIVE;
gc.fill = GridBagConstraints.BOTH;
gc.anchor = GridBagConstraints.CENTER;
gb.setConstraints(karnaughMap, gc);
add(karnaughMap);
Insets oldInsets = gc.insets;
gc.insets = new Insets(20, 0, 0, 0);
gb.setConstraints(minimizedExpr, gc);
add(minimizedExpr);
gc.insets = oldInsets;
gc.fill = GridBagConstraints.NONE;
gb.setConstraints(buttons, gc);
add(buttons);
String selected = selector.getSelectedOutput();
setAsExpr.setEnabled(selected != null && !outputExprs.isExpressionMinimal(selected));
}
示例15: AssociationRuleTableViewer
import java.awt.GridBagLayout; //导入方法依赖的package包/类
public AssociationRuleTableViewer(AssociationRules rules) {
if (rules != null && rules.getNumberOfRules() > 0) {
this.model = new AssociationRuleTableModel(rules);
setLayout(new BorderLayout());
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setBorder(null);
// conclusion list
AssociationRuleFilter filter = new AssociationRuleFilter(rules);
filter.addAssociationRuleFilterListener(this);
filter.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
splitPane.add(filter, 0);
// main panel
{
JPanel mainPanel = new JPanel();
mainPanel.setOpaque(true);
mainPanel.setBackground(Colors.WHITE);
GridBagLayout layout = new GridBagLayout();
mainPanel.setLayout(layout);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
c.insets = new Insets(15, 10, 10, 10);
table.setModel(model);
table.setRowHeight(PropertyPanel.VALUE_CELL_EDITOR_HEIGHT);
table.setRowHighlighting(true);
JScrollPane tablePane = new ExtendedJScrollPane(table);
tablePane.setBorder(null);
tablePane.setBackground(Colors.WHITE);
tablePane.getViewport().setBackground(Colors.WHITE);
layout.setConstraints(tablePane, c);
mainPanel.add(tablePane);
setColumnSizes();
splitPane.add(mainPanel, 1);
}
filter.triggerFilter();
add(splitPane, BorderLayout.CENTER);
} else {
add(ResultDisplayTools.createErrorComponent("No rules found"), BorderLayout.CENTER);
}
}