NONE源码实例Demo

java.awt.GridBagConstraints#NONE源码实例Demo

下面列出了java.awt.GridBagConstraints#NONE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CQL   文件: IdeOptions.java
private static JComponent pair(JComponent l, JComponent r) {
	JPanel pan = new JPanel(new GridBagLayout());
	GridBagConstraints c2 = new GridBagConstraints();
	c2.fill = GridBagConstraints.HORIZONTAL;
	c2.anchor = GridBagConstraints.LINE_START;
	c2.weightx = 1.0;

	GridBagConstraints c1 = new GridBagConstraints();
	c1.anchor = GridBagConstraints.WEST;
	c1.fill = GridBagConstraints.NONE;
	c1.weightx = 1.0;

	// JPanel ppp = new JPanel(new GridLayout(1, 1));
	// ppp.add(pan);
	pan.add(l, c2);
	pan.add(r, c1);
	return pan;
}
 
源代码2 项目: raccoon4   文件: UploadLogic.java
@Override
protected JPanel assemble() {

	progress = new JProgressBar();
	status = new HyperTextPane("                             ")
			.withTransparency().withWidth(400);

	JPanel ret = new JPanel();
	ret.setLayout(new GridBagLayout());
	GridBagConstraints gbc = new GridBagConstraints();
	gbc.anchor = GridBagConstraints.CENTER;
	gbc.fill = GridBagConstraints.NONE;
	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.insets.top = 20;
	ret.add(progress, gbc);
	gbc.weighty = 1;
	gbc.gridy++;
	gbc.fill = GridBagConstraints.BOTH;
	ret.add(status, gbc);
	return ret;
}
 
源代码3 项目: raccoon4   文件: LoginLogic.java
@Override
protected JPanel assemble() {
	progress = new JProgressBar();
	status = new HyperTextPane("                             ")
			.withTransparency().withWidth(400);

	JPanel ret = new JPanel();
	ret.setLayout(new GridBagLayout());
	GridBagConstraints gbc = new GridBagConstraints();
	gbc.anchor = GridBagConstraints.CENTER;
	gbc.fill = GridBagConstraints.NONE;
	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.insets.top = 20;
	ret.add(progress, gbc);
	gbc.weighty = 1;
	gbc.gridy++;
	gbc.fill = GridBagConstraints.BOTH;
	ret.add(status, gbc);
	return ret;
}
 
源代码4 项目: 3Dscript   文件: AnimationPanel.java
public AnimationPanel() {
	super();

	GridBagLayout gridbag = new GridBagLayout();
	GridBagConstraints c = new GridBagConstraints();
	setLayout(gridbag);

	JButton textbased = new JButton("Start text-based animation editor");
	textbased.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			fireTextBasedAnimation();
		}
	});
	c.anchor = GridBagConstraints.WEST;
	c.insets = new Insets(0, 2, 10, 5);
	c.gridwidth = GridBagConstraints.REMAINDER;
	c.fill = GridBagConstraints.NONE;
	c.gridx = 0;
	c.gridy++;
	add(textbased, c);
}
 
源代码5 项目: dummydroid   文件: CredentialsForm.java
public CredentialsForm(NavigateAction forwardAction, NavigateAction backwardAction) {
	super(forwardAction, backwardAction);
	username = new JTextField(20);
	password = new JPasswordField(20);
	JPanel content = new JPanel();
	GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST,
			GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 5, 5);
	content.setLayout(new GridBagLayout());
	content.add(new JLabel(Messages.getString("CredentialsForm.username")), gbc);
	gbc.gridx++;
	content.add(username, gbc);
	gbc.gridx = 0;
	gbc.gridy = 1;
	content.add(new JLabel(Messages.getString("CredentialsForm.password")), gbc);
	gbc.gridx++;
	gbc.weightx = 1;
	gbc.weighty = 1;
	content.add(password, gbc);
	content
			.setBorder(BorderFactory.createTitledBorder(Messages.getString("CredentialsForm.title")));
	// setLayout(new BorderLayout());
	add(content);
}
 
源代码6 项目: pumpernickel   文件: BoxTabbedPaneUI.java
protected GridBagConstraints createCloseButtonConstraints() {
	GridBagConstraints closeButtonConstraints = new GridBagConstraints();
	closeButtonConstraints.gridx = 0;
	closeButtonConstraints.gridy = 0;
	closeButtonConstraints.weightx = 1;
	closeButtonConstraints.weighty = 1;
	closeButtonConstraints.fill = GridBagConstraints.NONE;
	if (tabs.getTabPlacement() == SwingConstants.LEFT) {
		closeButtonConstraints.anchor = GridBagConstraints.SOUTH;
	} else if (tabs.getTabPlacement() == SwingConstants.RIGHT) {
		closeButtonConstraints.anchor = GridBagConstraints.NORTH;
	} else {
		closeButtonConstraints.anchor = GridBagConstraints.WEST;
	}
	if (tabs.getTabPlacement() == SwingConstants.LEFT) {
		closeButtonConstraints.insets = new Insets(0, 0, 3, 0);
	} else if (tabs.getTabPlacement() == SwingConstants.RIGHT) {
		closeButtonConstraints.insets = new Insets(3, 0, 0, 0);
	} else {
		closeButtonConstraints.insets = new Insets(0, 3, 0, 0);
	}
	return closeButtonConstraints;
}
 
源代码7 项目: spotbugs   文件: MainFrameComponentFactory.java
JPanel createSourceSearchPanel() {
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    JPanel thePanel = new JPanel();
    thePanel.setLayout(gridbag);
    mainFrame.getFindButton().setToolTipText("Find first occurrence");
    mainFrame.getFindNextButton().setToolTipText("Find next occurrence");
    mainFrame.getFindPreviousButton().setToolTipText("Find previous occurrence");
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1.0;
    c.insets = new Insets(0, 5, 0, 5);
    c.fill = GridBagConstraints.HORIZONTAL;
    gridbag.setConstraints(mainFrame.getSourceSearchTextField(), c);
    thePanel.add(mainFrame.getSourceSearchTextField());
    // add the buttons
    mainFrame.getFindButton().addActionListener(evt -> mainFrame.searchSource(0));
    c.gridx = 1;
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    gridbag.setConstraints(mainFrame.getFindButton(), c);
    thePanel.add(mainFrame.getFindButton());
    mainFrame.getFindNextButton().addActionListener(evt -> mainFrame.searchSource(1));
    c.gridx = 2;
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    gridbag.setConstraints(mainFrame.getFindNextButton(), c);
    thePanel.add(mainFrame.getFindNextButton());
    mainFrame.getFindPreviousButton().addActionListener(evt -> mainFrame.searchSource(2));
    c.gridx = 3;
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    gridbag.setConstraints(mainFrame.getFindPreviousButton(), c);
    thePanel.add(mainFrame.getFindPreviousButton());
    return thePanel;
}
 
private JPanel createPublishSettingsPanel() {
  final JComboBox fileFormat = new JComboBox( exportFormatModel );

  final GridBagConstraints c = new GridBagConstraints();
  final JPanel publishSettingsPanel = new JPanel( new GridBagLayout() );

  c.insets = new Insets( 5, 5, 0, 5 );
  c.gridwidth = 1;
  c.gridx = 0;
  c.gridy = 0;
  c.fill = GridBagConstraints.HORIZONTAL;
  c.anchor = GridBagConstraints.WEST;
  publishSettingsPanel
      .add( new JLabel( Messages.getInstance().getString( "RepositoryPublishDialog.OutputType" ) ), c );

  c.insets = new Insets( 5, 5, 5, 0 );
  c.gridwidth = 1;
  c.gridx = 0;
  c.gridy = 1;
  c.fill = GridBagConstraints.HORIZONTAL;
  c.anchor = GridBagConstraints.WEST;
  c.weightx = 0.0;
  publishSettingsPanel.add( fileFormat, c );

  c.insets = new Insets( 0, 5, 5, 5 );
  c.fill = GridBagConstraints.NONE;
  c.anchor = GridBagConstraints.WEST;
  c.gridx = 1;
  c.gridy = 1;
  c.weightx = 1.0;
  publishSettingsPanel.add( lockOutputTypeCheckBox, c );
  return publishSettingsPanel;
}
 
源代码9 项目: Pixelitor   文件: RGBPaletteConfig.java
@Override
public JPanel createConfigPanel(PalettePanel palettePanel) {
    var p = new JPanel(new GridBagLayout());

    crSlider = createSlider(cyanRed, "Cyan-red shift");
    crSlider.addChangeListener(e -> onNewRed(palettePanel));

    mgSlider = createSlider(magentaGreen, "Magenta-green shift");
    mgSlider.addChangeListener(e -> onNewGreen(palettePanel));

    ybSlider = createSlider(yellowBlue, "Yellow-Blue shift");
    ybSlider.addChangeListener(e -> onNewBlue(palettePanel));

    Insets insets = new Insets(2, 4, 2, 4);
    var labelCtr = new GridBagConstraints(0, 0, 1, 1, 0, 0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE, insets, 0, 0);
    var sliderCtr = new GridBagConstraints(1, 0, 1, 1, 1.0, 0,
            GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0);

    p.add(new JLabel("C-R:"), labelCtr);
    p.add(crSlider, sliderCtr);

    labelCtr.gridy = 1;
    p.add(new JLabel("M-G:"), labelCtr);
    sliderCtr.gridy = 1;
    p.add(mgSlider, sliderCtr);

    labelCtr.gridy = 2;
    p.add(new JLabel("Y-B:"), labelCtr);
    sliderCtr.gridy = 2;
    p.add(ybSlider, sliderCtr);

    return p;
}
 
源代码10 项目: openjdk-jdk8u   文件: ServiceDialog.java
public JobAttributesPanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);
    setBorder(BorderFactory.createTitledBorder(strTitle));

    c.fill = GridBagConstraints.NONE;
    c.insets = compInsets;
    c.weighty = 1.0;

    cbJobSheets = createCheckBox("checkbox.jobsheets", this);
    c.anchor = GridBagConstraints.LINE_START;
    addToGB(cbJobSheets, this, gridbag, c);

    JPanel pnlTop = new JPanel();
    lblPriority = new JLabel(getMsg("label.priority"), JLabel.TRAILING);
    lblPriority.setDisplayedMnemonic(getMnemonic("label.priority"));

    pnlTop.add(lblPriority);
    snModel = new SpinnerNumberModel(1, 1, 100, 1);
    spinPriority = new JSpinner(snModel);
    lblPriority.setLabelFor(spinPriority);
    // REMIND
    ((JSpinner.NumberEditor)spinPriority.getEditor()).getTextField().setColumns(3);
    spinPriority.addChangeListener(this);
    pnlTop.add(spinPriority);
    c.anchor = GridBagConstraints.LINE_END;
    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlTop.getAccessibleContext().setAccessibleName(
                               getMsg("label.priority"));
    addToGB(pnlTop, this, gridbag, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 0.0;
    c.gridwidth = 1;
    char jmnemonic = getMnemonic("label.jobname");
    lblJobName = new JLabel(getMsg("label.jobname"), JLabel.TRAILING);
    lblJobName.setDisplayedMnemonic(jmnemonic);
    addToGB(lblJobName, this, gridbag, c);
    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    tfJobName = new JTextField();
    lblJobName.setLabelFor(tfJobName);
    tfJobName.addFocusListener(this);
    tfJobName.setFocusAccelerator(jmnemonic);
    tfJobName.getAccessibleContext().setAccessibleName(
                                     getMsg("label.jobname"));
    addToGB(tfJobName, this, gridbag, c);

    c.weightx = 0.0;
    c.gridwidth = 1;
    char umnemonic = getMnemonic("label.username");
    lblUserName = new JLabel(getMsg("label.username"), JLabel.TRAILING);
    lblUserName.setDisplayedMnemonic(umnemonic);
    addToGB(lblUserName, this, gridbag, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    tfUserName = new JTextField();
    lblUserName.setLabelFor(tfUserName);
    tfUserName.addFocusListener(this);
    tfUserName.setFocusAccelerator(umnemonic);
    tfUserName.getAccessibleContext().setAccessibleName(
                                     getMsg("label.username"));
    addToGB(tfUserName, this, gridbag, c);
}
 
源代码11 项目: dragonwell8_jdk   文件: ServiceDialog.java
public JobAttributesPanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);
    setBorder(BorderFactory.createTitledBorder(strTitle));

    c.fill = GridBagConstraints.NONE;
    c.insets = compInsets;
    c.weighty = 1.0;

    cbJobSheets = createCheckBox("checkbox.jobsheets", this);
    c.anchor = GridBagConstraints.LINE_START;
    addToGB(cbJobSheets, this, gridbag, c);

    JPanel pnlTop = new JPanel();
    lblPriority = new JLabel(getMsg("label.priority"), JLabel.TRAILING);
    lblPriority.setDisplayedMnemonic(getMnemonic("label.priority"));

    pnlTop.add(lblPriority);
    snModel = new SpinnerNumberModel(1, 1, 100, 1);
    spinPriority = new JSpinner(snModel);
    lblPriority.setLabelFor(spinPriority);
    // REMIND
    ((JSpinner.NumberEditor)spinPriority.getEditor()).getTextField().setColumns(3);
    spinPriority.addChangeListener(this);
    pnlTop.add(spinPriority);
    c.anchor = GridBagConstraints.LINE_END;
    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlTop.getAccessibleContext().setAccessibleName(
                               getMsg("label.priority"));
    addToGB(pnlTop, this, gridbag, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 0.0;
    c.gridwidth = 1;
    char jmnemonic = getMnemonic("label.jobname");
    lblJobName = new JLabel(getMsg("label.jobname"), JLabel.TRAILING);
    lblJobName.setDisplayedMnemonic(jmnemonic);
    addToGB(lblJobName, this, gridbag, c);
    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    tfJobName = new JTextField();
    lblJobName.setLabelFor(tfJobName);
    tfJobName.addFocusListener(this);
    tfJobName.setFocusAccelerator(jmnemonic);
    tfJobName.getAccessibleContext().setAccessibleName(
                                     getMsg("label.jobname"));
    addToGB(tfJobName, this, gridbag, c);

    c.weightx = 0.0;
    c.gridwidth = 1;
    char umnemonic = getMnemonic("label.username");
    lblUserName = new JLabel(getMsg("label.username"), JLabel.TRAILING);
    lblUserName.setDisplayedMnemonic(umnemonic);
    addToGB(lblUserName, this, gridbag, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    tfUserName = new JTextField();
    lblUserName.setLabelFor(tfUserName);
    tfUserName.addFocusListener(this);
    tfUserName.setFocusAccelerator(umnemonic);
    tfUserName.getAccessibleContext().setAccessibleName(
                                     getMsg("label.username"));
    addToGB(tfUserName, this, gridbag, c);
}
 
源代码12 项目: moa   文件: ClusteringAlgoPanel.java
public void renderAlgoPanel(){

        setLayout(new BorderLayout());

        ArrayList<Option> options = new ArrayList<Option>();
        options.add(streamOption);
        options.add(algorithmOption0);
        options.add(algorithmOption1);

        JPanel optionsPanel = new JPanel();
        GridBagLayout gbLayout = new GridBagLayout();
        optionsPanel.setLayout(gbLayout);

        //Create generic label constraints
        GridBagConstraints gbcLabel = new GridBagConstraints();
        gbcLabel.gridx = 0;
        gbcLabel.fill = GridBagConstraints.NONE;
        gbcLabel.anchor = GridBagConstraints.EAST;
        gbcLabel.weightx = 0;
        gbcLabel.insets = new Insets(5, 5, 5, 5);

        //Create generic editor constraints
        GridBagConstraints gbcOption = new GridBagConstraints();
        gbcOption.gridx = 1;
        gbcOption.fill = GridBagConstraints.HORIZONTAL;
        gbcOption.anchor = GridBagConstraints.CENTER;
        gbcOption.weightx = 1;
        gbcOption.insets = new Insets(5, 5, 5, 0);

        //Stream Option
        JLabel labelStream = new JLabel("Stream");
        labelStream.setToolTipText("Stream to use.");
        optionsPanel.add(labelStream, gbcLabel);
        JComponent editorStream = getEditComponent(streamOption);
        labelStream.setLabelFor(editorStream);
        editComponents.add((OptionEditComponent) editorStream);
        optionsPanel.add(editorStream, gbcOption);

        //Algorithm0 Option
        JLabel labelAlgo0 = new JLabel("Algorithm1");
        labelAlgo0.setToolTipText("Algorithm to use.");
        optionsPanel.add(labelAlgo0, gbcLabel);
        JComponent editorAlgo0 = getEditComponent(algorithmOption0);
        labelAlgo0.setLabelFor(editorAlgo0);
        editComponents.add((OptionEditComponent) editorAlgo0);
        optionsPanel.add(editorAlgo0, gbcOption);

        //Algorithm1 Option
        JLabel labelAlgo1 = new JLabel("Algorithm2");
        labelAlgo1.setToolTipText("Comparison algorithm to use.");
        optionsPanel.add(labelAlgo1, gbcLabel);
        JComponent editorAlgo1 = getEditComponent(algorithmOption1);
        labelAlgo1.setLabelFor(editorAlgo1);
        editComponents.add((OptionEditComponent) editorAlgo1);
        optionsPanel.add(editorAlgo1, gbcOption);

        //use comparison Algorithm Option
        GridBagConstraints gbcClearButton = new GridBagConstraints();
        gbcClearButton.gridx = 2;
        gbcClearButton.gridy = 2;
        gbcClearButton.fill = GridBagConstraints.NONE;
        gbcClearButton.anchor = GridBagConstraints.CENTER;
        gbcClearButton.insets = new Insets(5, 0, 5, 5);

        JButton clearButton = new JButton("Clear");
        clearButton.addActionListener(this);
        clearButton.setActionCommand("clear");
        optionsPanel.add(clearButton, gbcClearButton);


        add(optionsPanel);
    }
 
源代码13 项目: megamek   文件: ChatLounge.java
private void setupMainPanel() {
    setupMap();

    panMain = new JPanel();

    // layout
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    panMain.setLayout(gridbag);

    c.fill = GridBagConstraints.VERTICAL;
    c.insets = new Insets(1, 1, 1, 1);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.gridwidth = 1;
    gridbag.setConstraints(butOptions, c);
    panMain.add(butOptions);

    JPanel panel1 = new JPanel(new GridBagLayout());
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0.0;
    c.anchor = GridBagConstraints.WEST;
    panel1.add(lblMapSummary, c);
    c.anchor = GridBagConstraints.WEST;
    c.gridx = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(0, 0, 0, 20);
    panel1.add(lblGameYear, c);
    c.gridx = 2;
    panel1.add(lblTechLevel, c);
    c.insets = new Insets(0, 0, 0, 0);
    c.fill = GridBagConstraints.VERTICAL;
    c.gridx = 3;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0.0;
    c.anchor = GridBagConstraints.NORTHEAST;
    panel1.add(butCompact, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHEAST;
    panMain.add(panel1, c);

    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridheight = 3;
    gridbag.setConstraints(scrEntities, c);
    panMain.add(scrEntities);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    gridbag.setConstraints(panUnitInfo, c);
    panMain.add(panUnitInfo);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.gridwidth = 1;
    c.gridheight = 1;
    gridbag.setConstraints(panPlayerInfo, c);
    panMain.add(panPlayerInfo);

    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 3;
    c.weightx = 0.0;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridheight = 1;
    gridbag.setConstraints(scrPlayers, c);
    panMain.add(scrPlayers);

    panTabs.add("Select Units", panMain); //$NON-NLS-1$
    panTabs.add("Select Map", panMap); //$NON-NLS-1$
}
 
源代码14 项目: KEEL   文件: PrintfApplet.java
private void initInputPanel(Panel p) {
   GridBagConstraints gbc=
     new GridBagConstraints();
   p.setLayout(new GridBagLayout());
   gbc.weightx=100;
   gbc.weighty=100;
   gbc.gridwidth=1;
   gbc.gridheight=1;
   gbc.fill=GridBagConstraints.HORIZONTAL;
   gbc.anchor=GridBagConstraints.WEST;

   gbc.gridx=0;
   gbc.gridy=0;
   Label typeLabel=new Label("Type");
   p.add(typeLabel,gbc);
   gbc.gridx=1;
   gbc.gridwidth=GridBagConstraints.REMAINDER;
   Label valueLabel=new Label("Value");
   p.add(valueLabel,gbc);

   gbc.gridx=0;
   gbc.gridy=1;
   Choice type=new Choice();
   type.add("Byte");
   type.add("Short");
   type.add("Character");
   type.add("Integer");
   type.add("Long");
   type.add("Float");
   type.add("Double");
   type.add("String");
   type.add("Object");
   type.select("Float");
   type.addItemListener(new TypeChoiceCommand());
   p.add(type,gbc);
   gbc.gridx=1;
   gbc.gridwidth=GridBagConstraints.REMAINDER;
   value=new ValueChoice();
   p.add(value,gbc);

   gbc.gridx=0;
   gbc.gridy=2;
   gbc.gridwidth=1;
   gbc.fill=GridBagConstraints.NONE;
   Button reset=new Button("Reset");
   reset.addActionListener(new ResetCommand());
   p.add(reset,gbc);
   gbc.gridx=1;
   gbc.gridwidth=GridBagConstraints.REMAINDER;
   Button position=new Button("Add");
   position.addActionListener(new AddCommand());
   p.add(position,gbc);

gbc.gridx=0;
gbc.gridy=3;
   gbc.gridwidth=1;
   gbc.gridheight=GridBagConstraints.REMAINDER;
   gbc.fill=GridBagConstraints.HORIZONTAL;
   Label format = new Label("Control String");
   p.add(format,gbc);
gbc.gridx=1;
   TextField formatString = new TextField(40);
   gbc.gridwidth=GridBagConstraints.REMAINDER;
   formatString.addTextListener(new FormatCommand());
   p.add(formatString,gbc);
 }
 
源代码15 项目: DominionSim   文件: DomBotEditor.java
private void fillPlayerPanel() {
  myPlayerPanel.removeAll();
     final GridBagConstraints theCons = DomGui.getGridBagConstraints( 2 );
     JLabel theLabel = new JLabel("Important!! These will be evaluated from top to bottom for each buy!!");
     theLabel.setForeground(Color.red);
     myPlayerPanel.add(theLabel,theCons);
     JButton theBTN = new JButton("Toggle View of Buy Conditions");
     theBTN.setMnemonic('T');
     theBTN.addActionListener(this);
     theBTN.setActionCommand("toggle conditions");
     theCons.gridy++;
     theCons.fill=GridBagConstraints.NONE;
     theCons.anchor=GridBagConstraints.CENTER;
     myPlayerPanel.add(theBTN,theCons);
     theCons.anchor=GridBagConstraints.NORTHWEST;
     theCons.fill=GridBagConstraints.BOTH;

     int i=0;
     theBTN = new JButton("Add a Buy Rule");
     theBTN.setMnemonic('A');
     theBTN.addActionListener(this);
     theBTN.setActionCommand("add rule " + i);
     theCons.gridy++;
     theCons.fill=GridBagConstraints.NONE;
     myPlayerPanel.add(theBTN,theCons);
     theCons.fill=GridBagConstraints.BOTH;

     for (DomBuyRulePanel thePanel : myBuyRulePanels){
   	i++;
   	theCons.gridy++;
    myPlayerPanel.add(thePanel, theCons);
     }

     theBTN = new JButton("Add a Buy Rule");
     theBTN.setMnemonic('B');
     theBTN.addActionListener(this);
     theBTN.setActionCommand("add rule "+i);
     theCons.gridy++;
     theCons.fill=GridBagConstraints.NONE;
     myPlayerPanel.add(theBTN,theCons);
     theCons.fill=GridBagConstraints.BOTH;

     theCons.gridy++;
     DomGui.addHeavyLabel(myPlayerPanel, theCons);

     validate();
}
 
源代码16 项目: DroidUIBuilder   文件: HardLayoutPane.java
/**
 * 按照指定的放置位置和占据的网格数,以指定的填充方式添加组件
 * 
 * @param willBeAddTo 要添加的组件
 * @param gridX 水平方向上网格位置
 * @param gridY 垂直方向上网格位置
 * @param gridWidth 水平方向上占据的网格个数
 * @param gridHeight 垂直方向上占据的网格个数
 * @param fill 填充方式
 * @see GridBagConstraints
 */
public Component addTo(Component willBeAddTo, int gridX, int gridY,
	int gridWidth, int gridHeight, int fill)
{
	gbc.gridx = gridX;
	gbc.gridy = gridY;
	gbc.gridwidth = gridWidth;
	gbc.gridheight = gridHeight;
	if (willBeAddTo instanceof javax.swing.JLabel &&
		((JLabel)willBeAddTo).getHorizontalAlignment() == javax.swing.JLabel.RIGHT)
	{
		gbc.anchor = GridBagConstraints.NORTHEAST;
	}
	else
	{
		gbc.anchor = GridBagConstraints.NORTHWEST;
	}
	switch (fill)
	{
		case GridBagConstraints.NONE:
			gbc.weightx = 0.0;
			gbc.weighty = 0.0;
			break;
		case GridBagConstraints.HORIZONTAL:
			gbc.weightx = 1.0;
			gbc.weighty = 0.0;
			break;
		case GridBagConstraints.VERTICAL:
			gbc.weightx = 0.0;
			gbc.weighty = 1.0;
			break;
		default:
			gbc.weightx = 1.0;
			gbc.weighty = 1.0;
	}
	gbc.fill = fill;
	
	//需要增加“回车移动焦点到下一组件上”监听事件
	if (addEnterKeyTrasfer)
		//给其它组件增加(文本组件已经UI里实现了
		addEnterKeyTransferFocusImplExceptText(willBeAddTo);
	this.fixedSubPane.add(willBeAddTo, gbc);
	return willBeAddTo;
}
 
源代码17 项目: megamek   文件: ChatLounge.java
/**
 * @param entity the entity to display the BV Calculation for
 */
private void mechBVDisplay(Entity entity) {
    final JDialog dialog = new JDialog(clientgui.frame, "BV Calculation Display", false);
    dialog.getContentPane().setLayout(new GridBagLayout());

    final int width = 500;
    final int height = 400;
    Dimension size = new Dimension(width, height);

    JEditorPane tEditorPane = new JEditorPane();
    tEditorPane.setContentType("text/html");
    tEditorPane.setEditable(false);
    tEditorPane.setBorder(null);
    entity.calculateBattleValue();
    tEditorPane.setText(entity.getBVText());
    tEditorPane.setCaretPosition(0);

    JScrollPane tScroll = new JScrollPane(tEditorPane,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tScroll.setBorder(null);
    tScroll.setPreferredSize(size);
    tScroll.setMinimumSize(size);

    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.0;
    gridBagConstraints.weighty = 1.0;
    dialog.getContentPane().add(tScroll, gridBagConstraints);

    JButton button = new JButton(Messages.getString("Okay"));
    button.addActionListener(e -> dialog.setVisible(false));
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    gridBagConstraints.anchor = GridBagConstraints.CENTER;
    gridBagConstraints.weighty = 0.0;
    dialog.getContentPane().add(button, gridBagConstraints);

    dialog.setSize(new Dimension(width + 25, height + 75));
    dialog.validate();
    dialog.setVisible(true);
}
 
源代码18 项目: openjdk-8-source   文件: ServiceDialog.java
public JobAttributesPanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);
    setBorder(BorderFactory.createTitledBorder(strTitle));

    c.fill = GridBagConstraints.NONE;
    c.insets = compInsets;
    c.weighty = 1.0;

    cbJobSheets = createCheckBox("checkbox.jobsheets", this);
    c.anchor = GridBagConstraints.LINE_START;
    addToGB(cbJobSheets, this, gridbag, c);

    JPanel pnlTop = new JPanel();
    lblPriority = new JLabel(getMsg("label.priority"), JLabel.TRAILING);
    lblPriority.setDisplayedMnemonic(getMnemonic("label.priority"));

    pnlTop.add(lblPriority);
    snModel = new SpinnerNumberModel(1, 1, 100, 1);
    spinPriority = new JSpinner(snModel);
    lblPriority.setLabelFor(spinPriority);
    // REMIND
    ((JSpinner.NumberEditor)spinPriority.getEditor()).getTextField().setColumns(3);
    spinPriority.addChangeListener(this);
    pnlTop.add(spinPriority);
    c.anchor = GridBagConstraints.LINE_END;
    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlTop.getAccessibleContext().setAccessibleName(
                               getMsg("label.priority"));
    addToGB(pnlTop, this, gridbag, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 0.0;
    c.gridwidth = 1;
    char jmnemonic = getMnemonic("label.jobname");
    lblJobName = new JLabel(getMsg("label.jobname"), JLabel.TRAILING);
    lblJobName.setDisplayedMnemonic(jmnemonic);
    addToGB(lblJobName, this, gridbag, c);
    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    tfJobName = new JTextField();
    lblJobName.setLabelFor(tfJobName);
    tfJobName.addFocusListener(this);
    tfJobName.setFocusAccelerator(jmnemonic);
    tfJobName.getAccessibleContext().setAccessibleName(
                                     getMsg("label.jobname"));
    addToGB(tfJobName, this, gridbag, c);

    c.weightx = 0.0;
    c.gridwidth = 1;
    char umnemonic = getMnemonic("label.username");
    lblUserName = new JLabel(getMsg("label.username"), JLabel.TRAILING);
    lblUserName.setDisplayedMnemonic(umnemonic);
    addToGB(lblUserName, this, gridbag, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    tfUserName = new JTextField();
    lblUserName.setLabelFor(tfUserName);
    tfUserName.addFocusListener(this);
    tfUserName.setFocusAccelerator(umnemonic);
    tfUserName.getAccessibleContext().setAccessibleName(
                                     getMsg("label.username"));
    addToGB(tfUserName, this, gridbag, c);
}
 
源代码19 项目: EchoSim   文件: TableLayout.java
private void parseSetting(GridBagConstraints gbc, String key, String val)
{
    int v;
    try
    {
        v = Integer.parseInt(val);
    }
    catch (NumberFormatException e)
    {
        v = 0;
    }
    if (key.equals("x") || key.equals("gridx"))
    {
        if (val.equals("."))
            gbc.gridx = currentX;
        else if (val.equals("+"))
            gbc.gridx = ++currentX;
        else
            gbc.gridx = v; 
    } 
    else if (key.equals("y") || key.equals("gridy"))
    {
        if (val.equals("."))
            gbc.gridy = currentY;
        else if (val.equals("+"))
            gbc.gridy = ++currentY;
        else
           gbc.gridy = v; 
    } 
    else if (key.equals("gridwidth") || key.equals("width"))
        gbc.gridwidth = v;
    else if (key.equals("gridheight") || key.equals("height"))
        gbc.gridheight = v;
    else if (key.equals("weightx"))
        gbc.weightx = v;
    else if (key.equals("weighty"))
        gbc.weighty = v;
    else if (key.equals("ipadx"))
        gbc.ipadx = v;
    else if (key.equals("ipady"))
        gbc.ipady = v;
    else if (key.equals("fill"))
    {
        if (val.equals("none"))
            gbc.fill = GridBagConstraints.NONE;
        else if (val.equals("horizontal") || val.equals("h"))
            gbc.fill = GridBagConstraints.HORIZONTAL;
        else if (val.equals("vertical") || val.equals("v"))
            gbc.fill = GridBagConstraints.VERTICAL;
        else if (val.equals("both") || val.equals("hv"))
            gbc.fill = GridBagConstraints.BOTH;
    }
    else if (key.equals("anchor"))
    {
        if (val.equals("center"))
            gbc.anchor = GridBagConstraints.CENTER;
        else if (val.equals("north") || val.equals("n"))
            gbc.anchor = GridBagConstraints.NORTH;
        else if (val.equals("northeast") || val.equals("ne"))
            gbc.anchor = GridBagConstraints.NORTHEAST;
        else if (val.equals("east") || val.equals("e"))
            gbc.anchor = GridBagConstraints.EAST;
        else if (val.equals("southeast") || val.equals("se"))
            gbc.anchor = GridBagConstraints.SOUTHEAST;
        else if (val.equals("south") || val.equals("s"))
            gbc.anchor = GridBagConstraints.SOUTH;
        else if (val.equals("southwest") || val.equals("sw"))
            gbc.anchor = GridBagConstraints.SOUTHWEST;
        else if (val.equals("west") || val.equals("w"))
            gbc.anchor = GridBagConstraints.WEST;
        else if (val.equals("northwest") || val.equals("nw"))
            gbc.anchor = GridBagConstraints.NORTHWEST;
    }
}
 
源代码20 项目: testing-cin   文件: Main.java
/**
 * Adds an UI component.
 * 
 * @param component
 *            The component.
 * @param x
 *            The column.
 * @param y
 *            The row.
 * @param width
 *            The number of columns to span.
 * @param height
 *            The number of rows to span.
 */
private void addComponent(Component component, int x, int y, int width, int height) {
    gc.gridx = x;
    gc.gridy = y;
    gc.gridwidth = width;
    gc.gridheight = height;
    gc.anchor = GridBagConstraints.CENTER;
    gc.fill = GridBagConstraints.NONE;
    gc.weightx = 0.0;
    gc.weighty = 0.0;
    getContentPane().add(component, gc);
}