java.awt.GridBagConstraints Java Examples

The following examples show how to use java.awt.GridBagConstraints. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NewProductDialog.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private JPanel createInfoPanel() {
    final JPanel infoPanel = GridBagUtils.createDefaultEmptyBorderPanel();
    infoPanel.setBorder(UIUtils.createGroupBorder("Output Product Information"));
    final GridBagConstraints gbc2 = GridBagUtils.createDefaultConstraints();
    GridBagUtils.addToPanel(infoPanel, new JLabel("Scene Width:"), gbc2);
    GridBagUtils.addToPanel(infoPanel, labelWidthInfo, gbc2);
    GridBagUtils.addToPanel(infoPanel, new JLabel("pixel"), gbc2, "weightx=1");
    GridBagUtils.addToPanel(infoPanel, new JLabel("Scene Height:"), gbc2, "gridy=1, weightx=0");
    GridBagUtils.addToPanel(infoPanel, labelHeightInfo, gbc2);
    GridBagUtils.addToPanel(infoPanel, new JLabel("pixel"), gbc2, "weightx=1");
    GridBagUtils.addToPanel(infoPanel, new JLabel("Center Latitude:"), gbc2, "gridy=2, weightx=0");
    GridBagUtils.addToPanel(infoPanel, labelCenterLatInfo, gbc2, "weightx=1, gridwidth=2");
    GridBagUtils.addToPanel(infoPanel, new JLabel("Center Longitude:"), gbc2, "gridy=3, weightx=0, gridwidth=1");
    GridBagUtils.addToPanel(infoPanel, labelCenterLonInfo, gbc2, "weightx=1, gridwidth=2");
    return infoPanel;
}
 
Example #2
Source File: UITools.java    From MtgDesktopCompanion with GNU General Public License v3.0 6 votes vote down vote up
public static GridBagConstraints createGridBagConstraints(Integer anchor,Integer fill,int col,int line)
{
	GridBagConstraints cons = new GridBagConstraints();
	
	if(anchor!=null)
		cons.anchor = anchor;
	
	if(fill!=null)
		cons.fill = fill;
	
	cons.insets = new Insets(0, 0, 5, 5);
	cons.gridx = col;
	cons.gridy = line;
	
	return cons;
}
 
Example #3
Source File: SectionSeparator.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private void initComponents(String text, Font font) {
    setBorder(BorderFactory.createEmptyBorder());
    setLayout(new GridBagLayout());
    setOpaque(false);

    label = new JLabel(text);
    label.setForeground(getForeground());
    if (font != null) label.setFont(font);
    else label.setFont(label.getFont().deriveFont(Font.BOLD));
    GridBagConstraints c1 = new GridBagConstraints();
    c1.weighty = 1d;
    add(label, c1);

    GridBagConstraints c2 = new GridBagConstraints();
    c2.weightx = 1d;
    c2.fill = GridBagConstraints.HORIZONTAL;
    c2.insets = new Insets(0, 4, 0, 0);
    add(new Separator(), c2);
}
 
Example #4
Source File: PluginQueryTokenizerPreferencesPanel.java    From bigtable-sql with Apache License 2.0 6 votes vote down vote up
private void addUseCustomQTCheckBox(JPanel panel, int col, int row)
{
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = col;
	c.gridy = row;
	c.insets = new Insets(5, 5, 0, 0);
	c.anchor = GridBagConstraints.WEST;
	c.gridwidth = 2; // Span across two columns
	useCustomQTCheckBox = new JCheckBox(i18n.USE_CUSTOM_QT_LABEL);
	useCustomQTCheckBox.setName("useCustomQTCheckBox");

	// i18n[PreferencesPanel.useCustomQTToolTip=Gives enhanced capabilities
	// over the default query tokenizer for handling {0} scripts]
	String USE_CUSTOM_QT_TOOLTIP =
		s_stringMgr.getString("PreferencesPanel.useCustomQTToolTip", _databaseName);

	useCustomQTCheckBox.setToolTipText(USE_CUSTOM_QT_TOOLTIP);
	useCustomQTCheckBox.addActionListener(new UseQTHandler());
	panel.add(useCustomQTCheckBox, c);
}
 
Example #5
Source File: ViewsPanel.java    From javamoney-examples with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a new views panel.
 */
public
ViewsPanel()
{
  setCardPanel(new JPanel(new CardLayout()));
  setView(null);
  setViewChooser(new ViewChooser());

  createViews();

  // Put the views into the cards.
  for(ViewKeys key : ViewKeys.values())
  {
    getCardPanel().add(getView(key), key.toString());
  }

  // Build panel.
  setFill(GridBagConstraints.BOTH);
  add(getViewChooser(), 0, 0, 1, 1, 100, 0);
  add(getCardPanel(), 0, 1, 1, 1, 0, 100);

  setInsets(new Insets(0, 10, 10, 10));
}
 
Example #6
Source File: XmlOptionPanelManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected int initAdditionalSyntaxButton( int gridy, 
        final TargetChooserPanel<FileType> panel,
        final TargetChooserPanelGUI<FileType> uiPanel) 
{
    myXmlSyntaxButton.setMnemonic(NbBundle.getMessage(XmlOptionPanelManager.class, 
            "A11Y_JspXml_mnem").charAt(0));
    getButtonGroup().add(myXmlSyntaxButton);
    myXmlSyntaxButton.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            checkBoxChanged(evt, panel, uiPanel);
        }
    });

    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = gridy++;
    gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    getOptionPanel().add(myXmlSyntaxButton, gridBagConstraints);
    return gridy;
}
 
Example #7
Source File: DocumentsPanelProvider.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private JPanel initUpperPanel() {
  JPanel panel = new JPanel(new GridBagLayout());
  panel.setOpaque(false);
  GridBagConstraints c = new GridBagConstraints();

  c.gridx = 0;
  c.gridy = 0;
  c.weightx = 0.5;
  c.anchor = GridBagConstraints.FIRST_LINE_START;
  c.fill = GridBagConstraints.HORIZONTAL;
  panel.add(initBrowseTermsPanel(), c);

  c.gridx = 1;
  c.gridy = 0;
  c.weightx = 0.5;
  c.anchor = GridBagConstraints.FIRST_LINE_START;
  c.fill = GridBagConstraints.HORIZONTAL;
  panel.add(initBrowseDocsByTermPanel(), c);

  return panel;
}
 
Example #8
Source File: CategoryTotalsFilterDialog.java    From javamoney-examples with Apache License 2.0 6 votes vote down vote up
private
Panel
createFilterPanel()
{
  Panel panel = new Panel();

  // Build panel.
  panel.setFill(GridBagConstraints.BOTH);
  panel.add(createChooserPanel(getChoosers()[ACCOUNTS], ACTION_ACCOUNTS), 0, 0, 1, 1, 50, 100);
  panel.addEmptyCellAt(1, 0);
  panel.add(createChooserPanel(getChoosers()[CATEGORIES], ACTION_CATEGORIES), 2, 0, 1, 1, 50, 0);
  panel.addEmptyCellAt(3, 0);
  panel.add(createChooserPanel(getChoosers()[PAYEES], ACTION_PAYEES), 4, 0, 1, 1, 50, 0);

  panel.setInsets(new Insets(10, 10, 10, 10));

  return panel;
}
 
Example #9
Source File: DetectPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void readSettings(WizardDescriptor settings) {           
    sources = null;
    sourcesString = null;
    javadoc = null;
    javadocString = null;
    this.wiz = settings;
    this.component.progressPanel.setVisible (true);
    this.component.progressLabel.setVisible (true);
    
    this.progressHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(DetectPanel.class,"TXT_PlatfromDetectProgress"));
    this.component.progressPanel.removeAll();
    this.component.progressPanel.setLayout (new GridBagLayout ());
    GridBagConstraints c = new GridBagConstraints ();
    c.gridx = c.gridy = GridBagConstraints.RELATIVE;
    c.gridheight = c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    JComponent pc = ProgressHandleFactory.createProgressComponent(this.progressHandle);
    ((GridBagLayout)this.component.progressPanel.getLayout ()).setConstraints(pc,c);
    this.component.progressPanel.add (pc);
    this.progressHandle.start ();
    task.schedule(0);
}
 
Example #10
Source File: DomBotSelector.java    From DominionSim with MIT License 6 votes vote down vote up
private JPanel getSelectionPanel() {
    final JPanel thePanel = new JPanel();
    thePanel.setLayout( new GridBagLayout() );
    final GridBagConstraints theCons = DomGui.getGridBagConstraints( 2 );
    JScrollPane theTypePane = new JScrollPane(getBotTypeList(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    theTypePane.setBorder(new TitledBorder( "Type" ));
    theCons.weightx = 0.0;
    theCons.weighty = 1.0;
    thePanel.add(theTypePane, theCons);

    theCons.weightx = 1.0;
    theCons.gridx++;
    thePanel.add(getBotPanel(), theCons);

    return thePanel;
}
 
Example #11
Source File: PropertiesDialog.java    From collect-earth with MIT License 6 votes vote down vote up
private JPanel getSqlLitePanel() {
	final JPanel panel = new JPanel(new GridBagLayout());
	final GridBagConstraints constraints = new GridBagConstraints();
	constraints.gridx = 0;
	constraints.gridy = 0;
	constraints.anchor = GridBagConstraints.LINE_START;
	constraints.insets = new Insets(5, 5, 5, 5);
	constraints.weightx = 1.0;
	constraints.fill = GridBagConstraints.HORIZONTAL;

	final Border border = new TitledBorder(new BevelBorder(BevelBorder.RAISED),
			Messages.getString("OptionWizard.30")); //$NON-NLS-1$
	panel.setBorder(border);

	panel.add(propertyToComponent.get(EarthProperty.AUTOMATIC_BACKUP)[0], constraints);
	constraints.gridx++;
	panel.add(getOpenBackupFolderButton());
	return panel;
}
 
Example #12
Source File: LoginLogic.java    From raccoon4 with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #13
Source File: Font2DTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void addLabeledComponentToGBL( String name,
                                       JComponent c,
                                       GridBagLayout gbl,
                                       GridBagConstraints gbc,
                                       Container target ) {
    LabelV2 l = new LabelV2( name );
    GridBagConstraints gbcLabel = (GridBagConstraints) gbc.clone();
    gbcLabel.insets = new Insets( 2, 2, 2, 0 );
    gbcLabel.gridwidth = 1;
    gbcLabel.weightx = 0;

    if ( c == null )
      c = new JLabel( "" );

    gbl.setConstraints( l, gbcLabel );
    target.add( l );
    gbl.setConstraints( c, gbc );
    target.add( c );
}
 
Example #14
Source File: PruebaCorrelacionIdiomas.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void anhadeTextAreaParaTextoAnalizado(Container contenedor) {
	areaDeTextoAAnalizar = new JTextArea();
       areaDeTextoAAnalizar.setLineWrap(true);
       areaDeTextoAAnalizar.setWrapStyleWord(true);
       areaDeTextoAAnalizar.setColumns(40);
       areaDeTextoAAnalizar.invalidate();

       JScrollPane scroll = new JScrollPane(areaDeTextoAAnalizar);
       scroll.setBorder(new TitledBorder("Escribe o copia aqu� un texto"));

       GridBagConstraints constraints = new GridBagConstraints();
       constraints.gridx = 0;
       constraints.gridy = 1;
       constraints.gridwidth = 4;
       constraints.gridheight = 1;
       constraints.weightx = 1.0;
       constraints.weighty = 1.0;
       constraints.fill = GridBagConstraints.BOTH;
       contenedor.add(scroll, constraints);
}
 
Example #15
Source File: HTMLEditOptionPanel.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method initializes this
 *
 * @return void
 */
private void initialize() {
    final GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
    gridBagConstraints3.gridx = 3;
    gridBagConstraints3.gridy = 0;
    final GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
    gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints2.gridy = 0;
    gridBagConstraints2.weightx = 1.0;
    gridBagConstraints2.gridx = 2;
    final GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
    gridBagConstraints1.gridx = 1;
    gridBagConstraints1.gridy = 0;
    final GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    jLabel = new JLabel();
    jLabel.setText(GlobalResourcesManager.getString("HTMLEditor.Programm"));
    this.setSize(300, 200);
    setLayout(new GridBagLayout());
    this.add(jLabel, gridBagConstraints);
    this.add(getJPanel(), gridBagConstraints1);
    this.add(getJTextField(), gridBagConstraints2);
    this.add(getJButton(), gridBagConstraints3);
}
 
Example #16
Source File: java_awt_GridBagConstraints.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected GridBagConstraints getObject() {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.gridwidth = 3;
    gbc.gridheight = 4;
    gbc.weightx = 0.1;
    gbc.weighty = 0.2;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.VERTICAL;
    gbc.insets.top = 1;
    gbc.insets.left = 2;
    gbc.insets.right = 3;
    gbc.insets.bottom = 4;
    gbc.ipadx = -1;
    gbc.ipady = -2;
    return gbc;
}
 
Example #17
Source File: DataElementPanel.java    From javamoney-examples with Apache License 2.0 6 votes vote down vote up
private
Panel
createNewPanel(ActionListener listener)
{
  Panel panel = new Panel();
  String key = getCollection().getType().toString().toLowerCase();
  Link link = new Link(getProperty("default") + " " + key, listener, ACTION_ADD);

  // Build link.
  link.setBackground(GUIConstants.COLOR_BACKGROUND_FILL);

  // Build panel.
  panel.setAnchor(GridBagConstraints.NORTHWEST);
  panel.add(link, 0, 0, 1, 1, 100, 100);

  panel.setBackground(GUIConstants.COLOR_BACKGROUND_FILL);
  panel.setBorder(createTitledBorder(""));

  return panel;
}
 
Example #18
Source File: CustomPayloadsOptionsPanel.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
public CustomPayloadsOptionsPanel() {
    this.tableModel = new CustomPayloadMultipleOptionsTableModel();
    this.tablePanel = new CustomPayloadsMultipleOptionsTablePanel(tableModel);
    this.setName(OPTIONS_TITLE);
    this.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.BOTH;

    this.add(new JLabel(OPTIONS_TITLE), gbc);
    gbc.weighty = 1.0;
    this.add(tablePanel, gbc);
}
 
Example #19
Source File: WebSocketUiHelper.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
public GridBagConstraints getLabelConstraints(int x, int y) {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new java.awt.Insets(0, 5, 0, 5);
    gbc.gridx = x;
    gbc.gridy = y;
    return gbc;
}
 
Example #20
Source File: ToolParameterPanel.java    From chipster with MIT License 5 votes vote down vote up
/**
 * Routine for adding component/label pair to a panel.
 * 
 * @param panel Panel that will contain the component.
 * @param component Control that will be added.
 * @param label JLabel object defining.
 * @param con Constraint object that defines Control's position.
 */
private void addParameter(JPanel panel, JComponent component, JLabel label,
                          GridBagConstraints con) {       
       con.gridx = 0;
       con.gridy++;
       con.insets.top = TOP_MARGIN;
       con.insets.left = LEFT_MARGIN;
       con.fill = GridBagConstraints.HORIZONTAL;
       panel.add(label, con);
       con.gridx = 1;
       con.anchor = GridBagConstraints.EAST;
       con.fill = GridBagConstraints.NONE;
       panel.add(component, con);
}
 
Example #21
Source File: ServiceDialog.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public OrientationPanel() {
    super();

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

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

    c.fill = GridBagConstraints.BOTH;
    c.insets = compInsets;
    c.weighty = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;

    ButtonGroup bg = new ButtonGroup();
    rbPortrait = new IconRadioButton("radiobutton.portrait",
                                     "orientPortrait.png", true,
                                     bg, this);
    rbPortrait.addActionListener(this);
    addToGB(rbPortrait, this, gridbag, c);
    rbLandscape = new IconRadioButton("radiobutton.landscape",
                                      "orientLandscape.png", false,
                                      bg, this);
    rbLandscape.addActionListener(this);
    addToGB(rbLandscape, this, gridbag, c);
    rbRevPortrait = new IconRadioButton("radiobutton.revportrait",
                                        "orientRevPortrait.png", false,
                                        bg, this);
    rbRevPortrait.addActionListener(this);
    addToGB(rbRevPortrait, this, gridbag, c);
    rbRevLandscape = new IconRadioButton("radiobutton.revlandscape",
                                         "orientRevLandscape.png", false,
                                         bg, this);
    rbRevLandscape.addActionListener(this);
    addToGB(rbRevLandscape, this, gridbag, c);
}
 
Example #22
Source File: PluginQueryTokenizerPreferencesPanel.java    From bigtable-sql with Apache License 2.0 5 votes vote down vote up
private void addStatementSeparatorTextField(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;
	statementSeparatorTextField = new JTextField(10);
	statementSeparatorTextField.setName("statementSeparatorTextField");

	statementSeparatorTextField.setHorizontalAlignment(JTextField.RIGHT);
	statementSeparatorTextField.setToolTipText(i18n.STMT_SEP_LABEL_TT);
	panel.add(statementSeparatorTextField, c);
}
 
Example #23
Source File: ServiceDialog.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private JLabel addLabel(String text,
                        GridBagLayout gridbag, GridBagConstraints c)
{
    c.gridwidth = 1;
    addToGB(new JLabel(text, JLabel.TRAILING), this, gridbag, c);

    c.gridwidth = GridBagConstraints.REMAINDER;
    JLabel label = new JLabel();
    addToGB(label, this, gridbag, c);

    return label;
}
 
Example #24
Source File: PropertiesUi.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
private void init() {
  setLayout(new GridBagLayout());
  // Create a blank label to use as a vertical fill so that the label/item pairs are aligned to
  // the top of the panel
  // and are not grouped in the center if the parent component is taller than the preferred size
  // of the panel.
  final GridBagConstraints constraints = new GridBagConstraints();
  constraints.gridx = 0;
  constraints.gridy = 99;
  constraints.insets = new Insets(10, 0, 0, 0);
  constraints.weighty = 1.0;
  constraints.fill = GridBagConstraints.VERTICAL;
  final JLabel verticalFillLabel = new JLabel();
  add(verticalFillLabel, constraints);
}
 
Example #25
Source File: DoubleSlider.java    From 3Dscript with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
}
 
Example #26
Source File: ScalarShapeFeaturesDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void makeLabel(String string, JPanel features, int row) {
	final JLabel label = new JLabel(string);
	label.setFont(FONT);

	final GridBagConstraints gbc = new GridBagConstraints();
	gbc.gridx = 0;
	gbc.gridy = row;
	gbc.anchor = GridBagConstraints.EAST;
	features.add(label, gbc);
}
 
Example #27
Source File: ExamplePanel.java    From ChatGameFontificator with The Unlicense 5 votes vote down vote up
private void build(ControlPanelBase basePanel)
{
    fontColorButton = new ColorButton("Font Tint", Color.WHITE, "Color to tint the font in the example image", basePanel);
    bgColorButton = new ColorButton("Backgroud", Color.DARK_GRAY.darker(), "Color to make the background", basePanel);
    lineFormatInput = new JTextField(TEXT_FONTNAME + " " + TEXT_PANGRAM + " " + TEXT_ASCII);
    JButton saveExample = new JButton("Generate/Save Example");
    saveExample.addActionListener(new ActionListener()
    {
        @Override
        public void actionPerformed(ActionEvent e)
        {
            generateExampleImage();
        }
    });

    GridBagConstraints gbc = ControlPanelBase.getGbc();
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0.0;
    add(fontColorButton, gbc);
    gbc.gridx++;
    add(bgColorButton, gbc);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0.9;
    gbc.gridx++;
    add(lineFormatInput, gbc);
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0.1;
    gbc.gridx++;
    add(saveExample, gbc);
}
 
Example #28
Source File: PolicyTool.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #29
Source File: ServiceDialog.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public OrientationPanel() {
    super();

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

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

    c.fill = GridBagConstraints.BOTH;
    c.insets = compInsets;
    c.weighty = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;

    ButtonGroup bg = new ButtonGroup();
    rbPortrait = new IconRadioButton("radiobutton.portrait",
                                     "orientPortrait.png", true,
                                     bg, this);
    rbPortrait.addActionListener(this);
    addToGB(rbPortrait, this, gridbag, c);
    rbLandscape = new IconRadioButton("radiobutton.landscape",
                                      "orientLandscape.png", false,
                                      bg, this);
    rbLandscape.addActionListener(this);
    addToGB(rbLandscape, this, gridbag, c);
    rbRevPortrait = new IconRadioButton("radiobutton.revportrait",
                                        "orientRevPortrait.png", false,
                                        bg, this);
    rbRevPortrait.addActionListener(this);
    addToGB(rbRevPortrait, this, gridbag, c);
    rbRevLandscape = new IconRadioButton("radiobutton.revlandscape",
                                         "orientRevLandscape.png", false,
                                         bg, this);
    rbRevLandscape.addActionListener(this);
    addToGB(rbRevLandscape, this, gridbag, c);
}
 
Example #30
Source File: PolicyTool.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Init the policy_entry_list TEXTAREA component in the
 * PolicyTool window
 */
void initPolicyList(JList policyList) {

    // add the policy list to the window
    //policyList.setPreferredSize(new Dimension(500, 350));
    JScrollPane scrollPane = new JScrollPane(policyList);
    addNewComponent(this, scrollPane, MW_POLICY_LIST,
                    0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.BOTH);
}