java.awt.GridBagLayout Java Examples

The following examples show how to use java.awt.GridBagLayout. 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: 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(1, 4, 0, 0);
    add(new SeparatorLine(), c2);
}
 
Example #2
Source File: UnitEditorDialog.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
private void initSystemPanel() {

        // systems are the hard part, because these are all unit specific
        // lets start with a mech
        panSystem = new JPanel(new GridBagLayout());
        panSystem.setBorder(BorderFactory.createTitledBorder(Messages.getString("UnitEditorDialog.system")));

        if (entity instanceof Mech) {
            setupMechSystemPanel();
        } else if (entity instanceof VTOL) {
            setupVtolSystemPanel();
        } else if (entity instanceof Tank) {
            setupTankSystemPanel();
        } else if (entity instanceof Aero) {
            setupAeroSystemPanel();
        } else if (entity instanceof Protomech) {
            setupProtoSystemPanel();
        }
    }
 
Example #3
Source File: Font2DTest.java    From dragonwell8_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 #4
Source File: TabbedPane.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public TabHeader( TabButton ... buttons ) {
    super( new GridBagLayout() );
    setOpaque(false);
    JPanel panelButtons = new JPanel( new GridLayout( 1, 0 ) );
    panelButtons.setOpaque( false );
    for( int i=0; i<buttons.length; i++ ) {
        TabButton btn = buttons[i];
        btn.setBorder(new TabBorder( i == buttons.length-1 ));
        panelButtons.add( btn );
    }

    add( Logo.createNetBeansLogo(), new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5,12,5,12), 0, 0) );
    add( new JLabel(), new GridBagConstraints( 1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0, 0) );
    add( panelButtons, new GridBagConstraints( 2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0,0,0,0), 0, 0) );
    add( new JLabel(), new GridBagConstraints( 3, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0, 0) );
    add( showNextTime, new GridBagConstraints( 4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(15,12,15,12), 0, 0) );
}
 
Example #5
Source File: UserAccountPanel.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
public UserAccountPanel() {
    // Create controls
    hyperlink = new Hyperlink();
    hyperlink.setText("");
    hyperlink.setActionCommand(CMD_SIGN_OUT);
    accountLabel = new JLabel();
    serverLabel = new JLabel();
    iconPanel = new IconPanel();

    // Layout controls
    setLayout(new GridBagLayout());
    SwingHelper.addToGridBag(this, iconPanel, 0, 0, 1, 2, 0, 4);
    SwingHelper.addToGridBag(this, serverLabel, 1, 0, 1, 1, 0, 4);
    SwingHelper.addToGridBag(this, accountLabel, 1, 1, 1, 1, 0, 4);
    SwingHelper.addToGridBag(this, hyperlink, 1, 2, 1, 1, 5, 4);

    setWindowsAccount(windowsAccount);
    setPreferredSize(new Dimension(64, 32));
}
 
Example #6
Source File: AccountToolbar.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
private void init() {
   setLayout(new GridBagLayout());
   GridBagConstraints gbc = new GridBagConstraints();

   gbc.anchor = GridBagConstraints.WEST;
   gbc.weightx = 0.0;
   add(new JButton(createBillingAccount), gbc.clone());
   gbc.weightx = 1.0;
   add(new JButton(updateBillingAccount), gbc.clone());
   gbc.weightx = 1.0;
   add(new JButton(delete), gbc.clone());

   gbc.anchor = GridBagConstraints.EAST;
   add(new JButton(refresh), gbc.clone());
   gbc.weightx = 0.0;
   add(new JButton(save), gbc.clone());
}
 
Example #7
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 #8
Source File: ViewModelListener.java    From netbeans with Apache License 2.0 6 votes vote down vote up
ViewModelListener(
    String viewType,
    JComponent view,
    JComponent buttonsPane,
    String propertiesHelpID,
    Image viewIcon
) {
    this.viewType = viewType;
    this.view = view;
    this.buttonsPane = buttonsPane;
    buttonsPane.setLayout(new GridBagLayout());
    this.propertiesHelpID = propertiesHelpID;
    this.viewIcon = viewIcon;
    initView();
    setUp();
}
 
Example #9
Source File: LinkButtonValueCellEditor.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates either a {@link LinkLocalButton} or a {@link LinkRemoteButton} that executes the
 * action stored in type.
 *
 * @param type
 *            the type
 */
public LinkButtonValueCellEditor(final ParameterTypeLinkButton type) {
	super(new JTextField());
	this.container = new JPanel(new GridBagLayout());
	this.container.setToolTipText(type.getDescription());

	GridBagConstraints gbc = new GridBagConstraints();

	if (type.isLocalAction()) {
		linkButton = new LinkLocalButton(type.getAction());
	} else {
		linkButton = new LinkRemoteButton(type.getAction());
	}
	gbc.gridx += 1;
	gbc.weightx = 1;
	gbc.fill = GridBagConstraints.HORIZONTAL;
	container.add(linkButton, gbc);
}
 
Example #10
Source File: QPopup.java    From pumpernickel with MIT License 6 votes vote down vote up
/**
 * Create a transparent window
 */
protected JWindow createWindow() {
	JWindow window = new JWindow();
	window.getRootPane().putClientProperty(PROPERTY_IS_QPOPUP, true);
	window.setType(Type.POPUP);
	window.getRootPane().putClientProperty("Window.shadow", Boolean.FALSE);
	float k = .95f;
	window.getRootPane().putClientProperty("Window.opacity", k);
	window.setOpacity(k);
	window.setBackground(new Color(0, 0, 0, 0));
	window.getRootPane().setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 1;
	c.fill = GridBagConstraints.BOTH;
	window.getRootPane().add(contents, c);
	return window;
}
 
Example #11
Source File: Font2DTest.java    From TencentKona-8 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 #12
Source File: Font2DTest.java    From hottub 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 #13
Source File: Attribute.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JPanel createPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.gridx = 0;

    createSection(getBorderSection(), "LBL_Border", panel, c); // NOI18N
    createSection(getTitleSection(), "LBL_Header_Footer", panel, c); // NOI18N
    createSection(getTextSection(), "LBL_Text", panel, c); // NOI18N
    createSection(getZoomSection(), "LBL_Zoom", panel, c); // NOI18N

    updateControl();

    return panel;
}
 
Example #14
Source File: AboutWindow.java    From wpcleaner with Apache License 2.0 6 votes vote down vote up
/**
 * @return Apache Commons Compress tab.
 */
private Component createCommonsCompressTab() {
  JPanel panel = new JPanel(new GridBagLayout());
  GridBagConstraints constraints = initializeGridBagConstraints();
  addPresentation(
      panel, constraints,
      "<html>" +
      "<b>Apache Commons Compress</b> is a component of Commons Apache project." +
      "<br>" +
      "The Apache Commons Compress library defines an API for working with ar, cpio, Unix dump, tar, zip, gzip, XZ, Pack200, bzip2, 7z, arj, lzma, snappy, DEFLATE and Z files." +
      "<br>" +
      "See <a href='http://commons.apache.org/proper/commons-compress/'>http://commons.apache.org/proper/commons-compress/</a> for more information." +
      "</html>");
  addFile(panel, constraints, "NOTICE_commons-compress.txt");
  addFile(panel, constraints, "LICENSE_commons-compress.txt");
  return createScrollPane(panel);
}
 
Example #15
Source File: VoiceMail.java    From Spark with Apache License 2.0 5 votes vote down vote up
public JPanel getToaster() {

        JPanel toaster = new JPanel();

        toaster.setLayout(new GridBagLayout());
        toaster.setBackground(Color.white);

        JLabel newVoiceMail = new JLabel();
        JLabel oldVoiceMail = new JLabel();

        newVoiceMail.setFont(new Font("Dialog", Font.BOLD, 15));
        newVoiceMail.setHorizontalAlignment(JLabel.CENTER);
        newVoiceMail.setText("New: " + this.getUnread());

        oldVoiceMail.setFont(new Font("Dialog", Font.PLAIN, 15));
        oldVoiceMail.setHorizontalAlignment(JLabel.CENTER);
        oldVoiceMail.setText("Old: " + this.getRead());

        final JLabel phoneImage = new JLabel(SparkRes
                .getImageIcon(SparkRes.MAIL_IMAGE_32x32));
        phoneImage.setHorizontalAlignment(JLabel.CENTER);
        phoneImage.setVerticalTextPosition(JLabel.BOTTOM);
        phoneImage.setHorizontalTextPosition(JLabel.CENTER);
        phoneImage.setText("Voice Mails");
        phoneImage.setFont(new Font("Dialog", Font.BOLD, 16));

        toaster.add(phoneImage, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                new Insets(5, 10, 0, 10), 0, 0));
        toaster.add(newVoiceMail, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0,
                GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
                new Insets(2, 0, 0, 0), 0, 0));
        toaster.add(oldVoiceMail, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
                GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
                new Insets(2, 0, 10, 0), 0, 0));

        return toaster;

    }
 
Example #16
Source File: BiographyInfoPane.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create a new instance of BiographyInfoPane.
 */
public BiographyInfoPane()
{
	this.itemsPanel = new JPanel();
	setLayout(new GridBagLayout());
	Box vbox = Box.createVerticalBox();

	itemsPanel.setLayout(new GridBagLayout());
	itemsPanel.setBorder(new EmptyBorder(8, 5, 8, 5));

	vbox.add(Box.createVerticalStrut(10));
	detailsScroll = new JScrollPane(itemsPanel);
	detailsScroll.setPreferredSize(detailsScroll.getMaximumSize());
	detailsScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	detailsScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
	detailsScroll.setMinimumSize(new Dimension(600, 0));
	vbox.add(detailsScroll);
	vbox.add(Box.createVerticalStrut(10));

	Box hbox = Box.createHorizontalBox();
	hbox.add(Box.createHorizontalGlue());
	JButton addCustomItemButton = new JButton();
	hbox.add(addCustomItemButton);
	hbox.add(Box.createHorizontalGlue());
	vbox.add(hbox);
	vbox.add(Box.createVerticalGlue());

	GridBagConstraints gbc = new GridBagConstraints();
	gbc.anchor = GridBagConstraints.NORTHWEST;
	gbc.weightx = 1;
	gbc.fill = GridBagConstraints.VERTICAL;
	gbc.weighty = 1;
	gbc.insets = new Insets(5, 5, 5, 5);
	add(vbox, gbc);
}
 
Example #17
Source File: java_awt_GridBagLayout.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected GridBagLayout getObject() {
    GridBagLayout layout = new GridBagLayout();
    update(layout, "1", 1, 1);
    update(layout, "2", 2, 2);
    update(layout, "3", 3, 3);
    return layout;
}
 
Example #18
Source File: ServiceDialog.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public MediaPanel() {
    super();

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

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

    cbSize = new JComboBox();
    cbSource = new JComboBox();

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

    c.weightx = 0.0;
    lblSize = new JLabel(getMsg("label.size"), JLabel.TRAILING);
    lblSize.setDisplayedMnemonic(getMnemonic("label.size"));
    lblSize.setLabelFor(cbSize);
    addToGB(lblSize, this, gridbag, c);
    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    addToGB(cbSize, this, gridbag, c);

    c.weightx = 0.0;
    c.gridwidth = 1;
    lblSource = new JLabel(getMsg("label.source"), JLabel.TRAILING);
    lblSource.setDisplayedMnemonic(getMnemonic("label.source"));
    lblSource.setLabelFor(cbSource);
    addToGB(lblSource, this, gridbag, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    addToGB(cbSource, this, gridbag, c);
}
 
Example #19
Source File: TitledPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private JPanel getSeparator() {
    final JSeparator separator = new JSeparator(JSeparator.HORIZONTAL);
    final JPanel separatorPanel = new JPanel(new GridBagLayout());
    final GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridy = 1;
    gbc.weighty = 0;
    gbc.weightx = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    separatorPanel.add(separator, gbc);
    return separatorPanel;
}
 
Example #20
Source File: ReportParametersPanel.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
public ReportParametersPanel() {		
	
	JScrollPane scroll = createBrowserTree();        
       createTable();
       
       setLayout(new GridBagLayout());
                       
       add(scroll, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
               GridBagConstraints.WEST, GridBagConstraints.BOTH,
               new Insets(0, 0, 0, 0), 0, 0));
       add(new JScrollPane(table), new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0,
               GridBagConstraints.WEST, GridBagConstraints.BOTH,
               new Insets(0, 5, 0, 0), 0, 0));                
}
 
Example #21
Source File: PolicyTool.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * displays a dialog box describing the status of an event
 */
void displayStatusDialog(Window w, String status) {
    ToolDialog sd = new ToolDialog
            (PolicyTool.getMessage("Status"), tool, this, true);

    // find the location of the PolicyTool gui
    Point location = ((w == null) ?
            getLocationOnScreen() : w.getLocationOnScreen());
    //sd.setBounds(location.x + 50, location.y + 50, 500, 100);
    sd.setLayout(new GridBagLayout());

    JLabel label = new JLabel(status);
    addNewComponent(sd, label, 0,
                    0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH);

    JButton okButton = new JButton(PolicyTool.getMessage("OK"));
    ActionListener okListener = new StatusOKButtonListener(sd);
    okButton.addActionListener(okListener);
    addNewComponent(sd, okButton, 1,
                    0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL);

    sd.getRootPane().setDefaultButton(okButton);
    sd.getRootPane().registerKeyboardAction(okListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW);

    sd.pack();
    sd.setLocationRelativeTo(w);
    sd.setVisible(true);
}
 
Example #22
Source File: ServiceDialog.java    From jdk8u_jdk 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 #23
Source File: OurUtil.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
public static JPanel makeGrid(int cols, GridBagConstraints template, Container... containers) {
    JPanel ans = new JPanel(new GridBagLayout());
    int i = -1;
    for (Container container : containers) {
        for (Component comp : container.getComponents()) {
            i++;
            GridBagConstraints c = (GridBagConstraints) template.clone();
            c.gridx = i % cols;
            c.gridy = i / cols;
            ans.add(comp, c);
        }
    }
    return ans;
}
 
Example #24
Source File: AnnotationStack.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
void init() {
  setLayout(new GridBagLayout());
  setOpaque(true);
  setBackground(Color.WHITE);
  stackRows = new ArrayList<StackRow>();
  textMouseListener = new StackMouseListener();
  headerMouseListener = new StackMouseListener();
  annotationMouseListener = new StackMouseListener();
}
 
Example #25
Source File: java_awt_GridBagLayout.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected GridBagLayout getObject() {
    GridBagLayout layout = new GridBagLayout();
    update(layout, "1", 1, 1);
    update(layout, "2", 2, 2);
    update(layout, "3", 3, 3);
    return layout;
}
 
Example #26
Source File: java_awt_GridBagLayout.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected GridBagLayout getAnotherObject() {
    GridBagLayout layout = new GridBagLayout();
    update(layout, "11", 1, 1);
    update(layout, "12", 1, 2);
    update(layout, "21", 2, 1);
    update(layout, "22", 2, 2);
    return layout;
}
 
Example #27
Source File: java_awt_GridBagLayout.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected GridBagLayout getAnotherObject() {
    GridBagLayout layout = new GridBagLayout();
    update(layout, "11", 1, 1);
    update(layout, "12", 1, 2);
    update(layout, "21", 2, 1);
    update(layout, "22", 2, 2);
    return layout;
}
 
Example #28
Source File: PalettePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void prepareSearchPanel() {
    if( searchpanel == null ) {
        searchpanel = new SearchPanel();

        JLabel lbl = new JLabel(NbBundle.getMessage(PalettePanel.class, "LBL_QUICKSEARCH")); //NOI18N
        searchpanel.setLayout(new GridBagLayout());
        searchpanel.add(lbl, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,0,0,5), 0, 0));
        searchpanel.add(searchTextField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,0,0,5), 0, 0));
        searchpanel.add(new JLabel(), new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,0,0,0), 0, 0));
        lbl.setLabelFor(searchTextField);
        searchTextField.setColumns(10);
        searchTextField.setMaximumSize(searchTextField.getPreferredSize());
        searchTextField.putClientProperty("JTextField.variant", "search"); //NOI18N
        lbl.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));

        JButton btnCancel = new JButton(ImageUtilities.loadImageIcon("org/netbeans/modules/palette/resources/cancel.png", true));
        btnCancel.setBorder(BorderFactory.createEmptyBorder());
        btnCancel.setBorderPainted(false);
        btnCancel.setOpaque(false);
        btnCancel.setContentAreaFilled(false);
        searchpanel.add(btnCancel, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0,0,0,5), 0, 0));
        btnCancel.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                removeSearchField();
            }
        });
    }
}
 
Example #29
Source File: CLMDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public JPanel getComponent(int width, int height) throws IOException {
	// the main panel
	final JPanel base = new JPanel();
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new GridBagLayout());
	vc = new VideoCaptureComponent(640, 480);
	vc.getDisplay().addVideoListener(this);
	base.add(vc);

	tracker.fcheck = true;

	return base;
}
 
Example #30
Source File: JDK8048887.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public TestDialog() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    for (int i=0; i < Xs.length; i++) {
        gbc.gridx = Xs[i];
        gbc.gridy = 100 - gbc.gridx;
        panel.add(new MyComponent(), gbc);
    }
    getRootPane().getContentPane().add(panel);
    pack();
}