Java Code Examples for java.awt.GridBagConstraints#BOTH

The following examples show how to use java.awt.GridBagConstraints#BOTH . 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: BombPayloadDialog.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
private void setupButtons() {
    butOK.addActionListener(this);
    butCancel.addActionListener(this);

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

    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(10, 5, 5, 5);
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.fill = GridBagConstraints.VERTICAL;
    c.ipadx = 20;
    c.ipady = 5;

    c.gridwidth = 1;
    gridbag.setConstraints(butOK, c);
    panButtons.add(butOK);

    c.gridwidth = GridBagConstraints.REMAINDER;
    gridbag.setConstraints(butCancel, c);
    panButtons.add(butCancel);
}
 
Example 2
Source File: SummaryInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void addGridBagLayer(JPanel panel, Font font, Insets insets, String text, JComponent comp)
{
	GridBagConstraints gbc = new GridBagConstraints();
	JLabel label = new JLabel(LanguageBundle.getString(text));
	label.setFont(font);
	gbc.anchor = GridBagConstraints.WEST;
	gbc.gridwidth = 2;
	panel.add(label, gbc);

	gbc.gridwidth = GridBagConstraints.REMAINDER;
	gbc.fill = GridBagConstraints.BOTH;
	if (insets != null)
	{
		gbc.insets = insets;
	}
	panel.add(comp, gbc);
}
 
Example 3
Source File: ServiceDialog.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public GeneralPanel() {
    super();

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

    setLayout(gridbag);

    c.fill = GridBagConstraints.BOTH;
    c.insets = panelInsets;
    c.weightx = 1.0;
    c.weighty = 1.0;

    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlPrintService = new PrintServicePanel();
    addToGB(pnlPrintService, this, gridbag, c);

    c.gridwidth = GridBagConstraints.RELATIVE;
    pnlPrintRange = new PrintRangePanel();
    addToGB(pnlPrintRange, this, gridbag, c);

    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlCopies = new CopiesPanel();
    addToGB(pnlCopies, this, gridbag, c);
}
 
Example 4
Source File: PruebaCorrelacionIdiomas.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void anhadeBotonCorrela(Container contenedor ) {
	GridBagConstraints constraints = new GridBagConstraints();
	JButton botonCorrela = new JButton("Analizar idioma");
       botonCorrela.addActionListener(
           new ActionListener()
           {
               public void actionPerformed(ActionEvent e)
               {
                   analizaTextoYExtraeResultados();
               }
           });

       constraints.gridx = 0;
       constraints.gridy = 0;
       constraints.gridwidth = 1;
       constraints.gridheight = 1;
       constraints.weightx = 0.0;
       constraints.weighty = 0.0;
       constraints.fill = GridBagConstraints.BOTH;
       contenedor.add(botonCorrela, constraints);
}
 
Example 5
Source File: PruebaCorrelacionIdiomas.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * A�ade bot�n para limpiar el area de texto con el texto de an�lisis.
 * 
 * @param contenedor
 */
private void anhadeBotonLimpiaTexto(Container contenedor ) {
	GridBagConstraints constraints = new GridBagConstraints();
	JButton limpiaTexto = new JButton("Borrar Texto");
       limpiaTexto.addActionListener(
           new ActionListener()
           {
               public void actionPerformed(ActionEvent e)
               {
                   areaDeTextoAAnalizar.setText("");
               }
           });
       constraints.gridx = 2;
       constraints.gridy = 0;
       constraints.gridwidth = 1;
       constraints.gridheight = 1;
       constraints.weightx = 0.0;
       constraints.weighty = 0.0;
       constraints.fill = GridBagConstraints.BOTH;
       contenedor.add(limpiaTexto, constraints);
}
 
Example 6
Source File: Test8039464.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void init(Container container) {
    container.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 1;
    JLabel label = new JLabel();
    Dimension size = new Dimension(111, 0);
    label.setPreferredSize(size);
    label.setMinimumSize(size);
    container.add(label, gbc);
    gbc.gridx = 1;
    gbc.weightx = 1;
    container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);
}
 
Example 7
Source File: ServiceDialog.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public QualityPanel() {
    super();

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

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

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

    ButtonGroup bg = new ButtonGroup();
    rbDraft = createRadioButton("radiobutton.draftq", this);
    bg.add(rbDraft);
    addToGB(rbDraft, this, gridbag, c);
    rbNormal = createRadioButton("radiobutton.normalq", this);
    rbNormal.setSelected(true);
    bg.add(rbNormal);
    addToGB(rbNormal, this, gridbag, c);
    rbHigh = createRadioButton("radiobutton.highq", this);
    bg.add(rbHigh);
    addToGB(rbHigh, this, gridbag, c);
}
 
Example 8
Source File: ErrorDialog.java    From pumpernickel with MIT License 6 votes vote down vote up
protected ThrowablePanel(ThrowableDescriptor t) {
	addThrowable(t);
	msg = getMessage(t);

	setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 1;
	c.fill = GridBagConstraints.BOTH;
	String informativeText = t.getInformativeText();
	if (informativeText == null)
		informativeText = t.throwable.getClass().getName();
	add(QDialog.createContentPanel(msg, informativeText, null, true), c);
	c.gridx++;
	c.weightx = 0;
	c.insets = new Insets(3, 3, 3, 3);
	add(multiplierLabel, c);

	multiplierLabel.setFont(multiplierLabel.getFont().deriveFont(
			Font.BOLD));
	multiplierLabel.setForeground(Color.lightGray);
}
 
Example 9
Source File: DecoratedDemo.java    From pumpernickel with MIT License 5 votes vote down vote up
public ListDemo() {
	setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 1;
	c.fill = GridBagConstraints.BOTH;
	add(getDecoratedComponent(), c);

	getDecoratedComponent().putClientProperty(
			DecoratedListUI.KEY_DECORATIONS,
			new ListDecoration[] { progressDecoration, starDecoration1,
					starDecoration2, starDecoration3, starDecoration4,
					starDecoration5, closeDecoration,
					playPauseDecoration, warningDecoration,
					refreshDecoration });

	getDecoratedComponent().setUI(new DecoratedListUI());
	LabelCellRenderer<String> r = new LabelCellRenderer<String>() {

		@Override
		protected void formatLabelColors(JComponent jc,
				boolean isSelected, int rowNumber) {
			super.formatLabelColors(jc, isSelected, rowNumber);
			if (isSelected) {
				label.setBackground(SystemColor.textHighlight);
				label.setForeground(SystemColor.textHighlightText);
			}
		}
	};
	getDecoratedComponent().setCellRenderer(r);
	getDecoratedComponent().setFixedCellHeight(24);
	getDecoratedComponent().setPreferredSize(new Dimension(200, 150));
}
 
Example 10
Source File: ServiceDialog.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public SidesPanel() {
    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();
    rbOneSide = new IconRadioButton("radiobutton.oneside",
                                    "oneside.png", true,
                                    bg, this);
    rbOneSide.addActionListener(this);
    addToGB(rbOneSide, this, gridbag, c);
    rbTumble = new IconRadioButton("radiobutton.tumble",
                                   "tumble.png", false,
                                   bg, this);
    rbTumble.addActionListener(this);
    addToGB(rbTumble, this, gridbag, c);
    rbDuplex = new IconRadioButton("radiobutton.duplex",
                                   "duplex.png", false,
                                   bg, this);
    rbDuplex.addActionListener(this);
    c.gridwidth = GridBagConstraints.REMAINDER;
    addToGB(rbDuplex, this, gridbag, c);
}
 
Example 11
Source File: FormView.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
private void init() {
   labelConstraints = new GridBagConstraints();
   labelConstraints.gridx = 0;
   labelConstraints.gridy = 0;
   labelConstraints.weightx = 0.0;
   labelConstraints.weighty = 0.0;
   labelConstraints.fill = GridBagConstraints.NONE;
   labelConstraints.anchor = GridBagConstraints.EAST;

   fieldConstraints = new GridBagConstraints();
   fieldConstraints.gridx = 1;
   fieldConstraints.gridy = 0;
   fieldConstraints.weightx = 1.0;
   fieldConstraints.weighty = 0.0;
   fieldConstraints.fill = GridBagConstraints.HORIZONTAL;
   
   wideLabelConstraints = new GridBagConstraints();
   wideLabelConstraints.gridx = 0;
   wideLabelConstraints.gridy = 0;
   wideLabelConstraints.gridwidth = 2;
   wideLabelConstraints.weightx = 1.0;
   wideLabelConstraints.weighty = 0.0;
   wideLabelConstraints.fill = GridBagConstraints.HORIZONTAL;

   wideFieldConstraints = new GridBagConstraints();
   wideFieldConstraints.gridx = 0;
   wideFieldConstraints.gridy = 0;
   wideFieldConstraints.gridwidth = 2;
   wideFieldConstraints.weightx = 1.0;
   wideFieldConstraints.weighty = 1.0;
   wideFieldConstraints.fill = GridBagConstraints.BOTH;
   
   componentConstraints = (GridBagConstraints) wideFieldConstraints.clone();
   
   GridBagConstraints buttonConstraints = (GridBagConstraints) wideLabelConstraints.clone();
   buttonConstraints.gridy = 1000;
   
   panel.add(buttons, buttonConstraints);
}
 
Example 12
Source File: ServiceDialog.java    From jdk8u-dev-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 13
Source File: RunConvertPanel.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setupDisplay(JPanel panel, CDOMObject pc)
{
	panel.setLayout(new GridBagLayout());

	JLabel introLabel = new JLabel("Conversion in progress");
	GridBagConstraints gbc = new GridBagConstraints();
	Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0);
	gbc.fill = GridBagConstraints.HORIZONTAL;
	gbc.insets = new Insets(0, 10, 5, 10);
	panel.add(introLabel, gbc);

	JLabel explainLabel = new JLabel("<html>The LST data is being converted. In the log, "
		+ "LSTERROR rows are errors that need to be manually corrected in the source data. "
		+ "LSTWARN rows indicate changes the converter is making. " + "See " + changeLogFile.getAbsolutePath()
		+ " for a log of all data changes.</html>");
	explainLabel.setFocusable(true);
	Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0);
	gbc.fill = GridBagConstraints.HORIZONTAL;
	gbc.insets = new Insets(0, 10, 5, 10);
	panel.add(explainLabel, gbc);

	progressBar = getProgressBar();
	Dimension d = progressBar.getPreferredSize();
	d.width = 400;
	progressBar.setPreferredSize(d);
	progressBar.setStringPainted(true);
	Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0);
	gbc.fill = GridBagConstraints.HORIZONTAL;
	panel.add(progressBar, gbc);

	Component messageAreaContainer = new JScrollPane(getMessageArea());
	Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0);
	gbc.fill = GridBagConstraints.BOTH;
	panel.add(messageAreaContainer, gbc);

	panel.setPreferredSize(new Dimension(800, 500));
}
 
Example 14
Source File: TemplateEditForm.java    From code-generator with Apache License 2.0 5 votes vote down vote up
private void initEditor(String template) {
    EditorFactory factory = EditorFactory.getInstance();
    Document velocityTemplate = factory.createDocument(template);
    editor = factory.createEditor(velocityTemplate, null, FileTypeManager.getInstance()
        .getFileTypeByExtension("vm"), false);
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 1;
    constraints.weighty = 1;
    editPanel.add(editor.getComponent(), constraints);
}
 
Example 15
Source File: PropertiesDialog.java    From collect-earth with MIT License 5 votes vote down vote up
private JComponent getSampleDataPanel() {
	final JPlotCsvTable samplePlots = new JPlotCsvTable(localPropertiesService.getValue(EarthProperty.SAMPLE_FILE),
			surveyLoaded);

	final JPanel panel = new JPanel(new GridBagLayout());
	final GridBagConstraints constraints = new GridBagConstraints();
	constraints.gridx = 0;
	constraints.gridy = 0;
	constraints.fill = GridBagConstraints.BOTH;
	constraints.insets = new Insets(5, 5, 5, 5);
	constraints.weightx = 1.0;

	final JFilePicker refreshTableOnFileChange = getFilePickerSamplePlots(samplePlots);

	panel.add(refreshTableOnFileChange, constraints);

	samplePlots.setFillsViewportHeight(true);
	constraints.gridy = 1;

	constraints.weightx = 1.0;
	constraints.weighty = 1.0;
	constraints.gridwidth = GridBagConstraints.REMAINDER;
	constraints.gridheight = GridBagConstraints.REMAINDER;

	samplePlots.setPreferredScrollableViewportSize(samplePlots.getPreferredSize());

	panel.add(new JScrollPane(samplePlots, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), constraints);

	return panel;
}
 
Example 16
Source File: DomBotEditor.java    From DominionSim with MIT License 4 votes vote down vote up
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();
}
 
Example 17
Source File: GUI.java    From allsummarizer with Apache License 2.0 4 votes vote down vote up
public GUI(){ 
	super("Easy Summarization");
	
	menuBar = new Menu(this);
       setJMenuBar(menuBar);
       
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	int espaceX=(screenSize.width-800)/2;
	int espaceY=(screenSize.height-600)/2;
	setBounds(espaceX, espaceY, 800, 570); 
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      
	GridBagLayout gridBagLayout = new GridBagLayout();
	gridBagLayout.columnWidths = new int[]{123, 621, 0};
	gridBagLayout.rowHeights = new int[]{20, 150, 150, 150, 0};
	gridBagLayout.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
	gridBagLayout.rowWeights = new double[]{0.1, 0.3, 0.3, 0.3, Double.MIN_VALUE};
	getContentPane().setLayout(gridBagLayout);
	
	JButton b= new JButton("Summarize");
	MouseListener mouseListener = new MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				faire(txt.getText());
				
			}
		};

	b.addMouseListener(mouseListener);
	GridBagConstraints gbc_b11 = new GridBagConstraints();
	gbc_b11.insets = new Insets(0, 0, 5, 5);
	gbc_b11.gridx = 0;
	gbc_b11.gridy = 0;
	gbc_b11.fill= GridBagConstraints.BOTH;
	getContentPane().add(b, gbc_b11);
		
		panel = new ToolBar();
		GridBagConstraints gbc_panel = new GridBagConstraints();
		gbc_panel.insets = new Insets(0, 0, 5, 0);
		gbc_panel.fill = GridBagConstraints.BOTH;
		gbc_panel.gridx = 1;
		gbc_panel.gridy = 0;
		getContentPane().add(panel, gbc_panel);
		
		
	
	//txt.setSize(20,200);
		//txt.setBounds(0, 0, 10, 20);
		txt.setLineWrap(true);
		JScrollPane txtscrl = new JScrollPane(txt);
		//txtscrl.setSize(0, 100);
		///txtscrl.setPreferredSize(new java.awt.Dimension(120, 100));
		//txtscrl.setPreferredSize(new java.awt.Dimension(770, 100));
	GridBagConstraints gbc_b21 = new GridBagConstraints();
	gbc_b21.fill = GridBagConstraints.BOTH;
	gbc_b21.insets = new Insets(0, 0, 5, 0);
	gbc_b21.gridwidth = 2;
	gbc_b21.gridx = 0;
	gbc_b21.gridy = 1;
	getContentPane().add(txtscrl, gbc_b21);
	
	//JButton b31 = new JButton("New button");
	JScrollPane lsscrl = new JScrollPane(myList);
	GridBagConstraints gbc_b31 = new GridBagConstraints();
	gbc_b31.fill = GridBagConstraints.BOTH;
	gbc_b31.insets = new Insets(0, 0, 5, 0);
	gbc_b31.gridwidth = 2;
	gbc_b31.gridx = 0;
	gbc_b31.gridy = 2;
	getContentPane().add(lsscrl, gbc_b31);
	
	txt2.setLineWrap(true);
	JScrollPane txt2scrl = new JScrollPane(txt2);
	GridBagConstraints gbc_b41 = new GridBagConstraints();
	gbc_b41.fill = GridBagConstraints.BOTH;
	gbc_b41.gridwidth = 2;
	gbc_b41.gridx = 0;
	gbc_b41.gridy = 3;
	getContentPane().add(txt2scrl, gbc_b41);
	
	setVisible(true);
	
}
 
Example 18
Source File: ServiceDialog.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public PrintServicePanel() {
    super();

    uiFactory = psCurrent.getServiceUIFactory();

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

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

    String[] psnames = new String[services.length];
    for (int i = 0; i < psnames.length; i++) {
        psnames[i] = services[i].getName();
    }
    cbName = new JComboBox(psnames);
    cbName.setSelectedIndex(defaultServiceIndex);
    cbName.addItemListener(this);
    cbName.addPopupMenuListener(this);

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

    c.weightx = 0.0;
    JLabel lblName = new JLabel(getMsg("label.psname"), JLabel.TRAILING);
    lblName.setDisplayedMnemonic(getMnemonic("label.psname"));
    lblName.setLabelFor(cbName);
    addToGB(lblName, this, gridbag, c);
    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.RELATIVE;
    addToGB(cbName, this, gridbag, c);
    c.weightx = 0.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    btnProperties = createButton("button.properties", this);
    addToGB(btnProperties, this, gridbag, c);

    c.weighty = 1.0;
    lblStatus = addLabel(getMsg("label.status"), gridbag, c);
    lblStatus.setLabelFor(null);

    lblType = addLabel(getMsg("label.pstype"), gridbag, c);
    lblType.setLabelFor(null);

    c.gridwidth = 1;
    addToGB(new JLabel(getMsg("label.info"), JLabel.TRAILING),
            this, gridbag, c);
    c.gridwidth = GridBagConstraints.RELATIVE;
    lblInfo = new JLabel();
    lblInfo.setLabelFor(null);

    addToGB(lblInfo, this, gridbag, c);

    c.gridwidth = GridBagConstraints.REMAINDER;
    cbPrintToFile = createCheckBox("checkbox.printtofile", this);
    addToGB(cbPrintToFile, this, gridbag, c);

    filePermission = allowedToPrintToFile();
}
 
Example 19
Source File: StartingPositionDialog.java    From megamek with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new instance of StartingPositionDialog
 */
public StartingPositionDialog(ClientGUI clientgui) {
    super(clientgui.frame, Messages
            .getString("StartingPositionDialog.title"), true); //$NON-NLS-1$
    client = clientgui.getClient();
    this.clientgui = clientgui;

    lisStartList.setEnabled(false);

    setupStartGrid();
    setupButtons();

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

    c.fill = GridBagConstraints.VERTICAL;
    c.insets = new Insets(4, 4, 4, 4);
    c.gridwidth = 1;
    gridbag.setConstraints(panStartButtons, c);
    getContentPane().add(panStartButtons);

    c.weightx = 1.0;
    c.weighty = 1.0;
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    JScrollPane sp = new JScrollPane(lisStartList);
    gridbag.setConstraints(sp, c);
    getContentPane().add(sp);

    c.fill = GridBagConstraints.NONE;
    gridbag.setConstraints(panButtons, c);
    getContentPane().add(panButtons);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            setVisible(false);
        }
    });

    pack();
    setResizable(false);
    setLocation((clientgui.frame.getLocation().x
            + (clientgui.frame.getSize().width / 2)) - (getSize().width / 2),
            (clientgui.frame.getLocation().y
                    + (clientgui.frame.getSize().height / 2))
                    - (getSize().height / 2));
}
 
Example 20
Source File: TabTitle.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
public TabTitle(@Nonnull final Context context, @Nonnull final TabProvider parent, @Nullable final File associatedFile) {
  super(new GridBagLayout());
  this.parent = parent;
  this.context = context;
  this.associatedFile = associatedFile;
  this.changed = this.associatedFile == null;
  this.setOpaque(false);
  final GridBagConstraints constraints = new GridBagConstraints();
  constraints.fill = GridBagConstraints.BOTH;
  constraints.weightx = 1000.0d;

  final TabTitle theInstance = this;

  this.titleLabel = new JLabel() {
    private static final long serialVersionUID = 8689945842487138781L;

    @Override
    protected void processKeyEvent(@Nonnull final KeyEvent e) {
      theInstance.getParent().dispatchEvent(e);
    }

    @Override
    public String getToolTipText() {
      return theInstance.getToolTipText();
    }

    @Override
    public boolean isFocusable() {
      return false;
    }
  };
  this.add(this.titleLabel, constraints);

  final Icon uiCloseIcon = UIManager.getIcon("InternalFrameTitlePane.closeIcon"); //NOI18N

  this.closeButton = new JButton(uiCloseIcon == null ? NIMBUS_CLOSE_ICON : uiCloseIcon) {
    private static final long serialVersionUID = -8005282815756047979L;

    @Override
    public String getToolTipText() {
      return theInstance.getToolTipText();
    }

    @Override
    public boolean isFocusable() {
      return false;
    }
  };
  this.closeButton.setToolTipText("Close tab");
  this.closeButton.setBorder(null);
  this.closeButton.setContentAreaFilled(false);
  this.closeButton.setMargin(new Insets(0, 0, 0, 0));
  this.closeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  this.closeButton.setOpaque(false);
  this.closeButton.addActionListener(e -> doSafeClose());
  constraints.fill = GridBagConstraints.BOTH;
  constraints.weightx = 0.0d;
  constraints.insets = new Insets(2, 8, 2, 0);

  this.add(this.closeButton, constraints);

  updateView();

  ToolTipManager.sharedInstance().registerComponent(closeButton);
  ToolTipManager.sharedInstance().registerComponent(this.titleLabel);
  ToolTipManager.sharedInstance().registerComponent(this);
}