Java Code Examples for java.awt.GridBagConstraints#CENTER

The following examples show how to use java.awt.GridBagConstraints#CENTER . 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: Attribute.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void setMacroPanel(JPanel panel, GridBagConstraints c) {
    JPanel p = new JPanel(new GridBagLayout());

    // macros
    c.gridy++;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    panel.add(createLabel(i18n("LBL_Insert_Macros")), c); // NOI18N

    // buttons
    c.anchor = GridBagConstraints.CENTER;

    for (Macro macro : Macro.values()) {
        JButton button = macro.getButton(this);
        setWidth(button, MACROS_WIDTH);
        p.add(button, c);
    }
    //
    c.weightx = 1.0;
    c.insets = new Insets(LARGE_SIZE, LARGE_SIZE, TINY_SIZE, 0);
    c.gridwidth = 1 + 1 + 1;
    panel.add(p, c);
    c.gridwidth = 1;
}
 
Example 2
Source File: Stacker.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
 * Fades in the specified message component in the top layer of this
 * layered pane.
 * @param message the component to be displayed in the message layer
 * @param finalAlpha the alpha value of the component when fade in is complete
 */
public void showMessageLayer(JComponent message, final float finalAlpha) {
    messageLayer = new JPanel();
    messageLayer.setOpaque(false);
    GridBagLayout gridbag = new GridBagLayout();
    messageLayer.setLayout(gridbag);
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.CENTER;

    messageAlpha = new JXPanel();
    messageAlpha.setOpaque(false);
    messageAlpha.setAlpha(0.0f);
    gridbag.addLayoutComponent(messageAlpha, c);
    messageLayer.add(messageAlpha);
    messageAlpha.add(message);

    add(messageLayer, JLayeredPane.POPUP_LAYER);
    revalidate();
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            Animator animator = new Animator(2000,
                    new PropertySetter(messageAlpha, "alpha", 0.0f, finalAlpha));
            animator.setStartDelay(200);
            animator.setAcceleration(.2f);
            animator.setDeceleration(.5f);
            animator.start();
        }
    });
}
 
Example 3
Source File: ConnectionPropertiesPanel.java    From bigtable-sql with Apache License 2.0 5 votes vote down vote up
private JPanel getSleepTimePanel()
{
	JPanel sleepTimePanel = new JPanel();
	sleepTimePanel.setLayout(new GridBagLayout());
	
	SpinnerNumberModel spinnerNumberModel = 
		new SpinnerNumberModel(_props.getKeepAliveSleepTimeSeconds(), 10, Integer.MAX_VALUE, 10);
	sleepTime = new JSpinner(spinnerNumberModel);
	sleepTime.setPreferredSize(new Dimension(75, 25));

	sleepForLabel = new JLabel(i18n.SLEEP_FOR_LABEL);
	
	GridBagConstraints gbc = new GridBagConstraints();
	gbc.anchor = GridBagConstraints.EAST;
	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.weightx = .05;
	gbc.insets = new Insets(0, 5, 0, 0);
	sleepTimePanel.add(sleepForLabel, gbc);

	gbc.anchor = GridBagConstraints.CENTER;
	gbc.gridx++;
	gbc.weightx = .05;
	sleepTimePanel.add(sleepTime, gbc);

	secondsLabel = new JLabel(i18n.SECONDS_LABEL);
	
	gbc.anchor = GridBagConstraints.WEST;
	gbc.gridx++;
	gbc.weightx = .9;
	sleepTimePanel.add(secondsLabel, gbc);

	return sleepTimePanel;
}
 
Example 4
Source File: RGBPaletteConfig.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example 5
Source File: XPlottingViewer.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void setupDisplay(Plotter p) {
    final JPanel buttonPanel = new JPanel();
    final GridBagLayout gbl = new GridBagLayout();
    buttonPanel.setLayout(gbl);
    setLayout(new BorderLayout());
    plotButton = new JButton(Resources.getText("LBL_DiscardChart")); // NOI18N
    plotButton.addActionListener(this);
    plotButton.setEnabled(true);

    GridBagConstraints buttonConstraints = new GridBagConstraints();
    buttonConstraints.gridx = 0;
    buttonConstraints.gridy = 0;
    buttonConstraints.fill = GridBagConstraints.VERTICAL;
    buttonConstraints.anchor = GridBagConstraints.CENTER;
    gbl.setConstraints(plotButton, buttonConstraints);
    buttonPanel.add(plotButton);

    if (attributeName != null && attributeName.length()!=0) {
        final JPanel plotterLabelPanel = new JPanel();
        final JLabel atlabel = new JLabel(attributeName);
        final GridBagLayout gbl2 = new GridBagLayout();
        plotterLabelPanel.setLayout(gbl2);
        final GridBagConstraints labelConstraints = new GridBagConstraints();
        labelConstraints.gridx = 0;
        labelConstraints.gridy = 0;
        labelConstraints.fill = GridBagConstraints.VERTICAL;
        labelConstraints.anchor = GridBagConstraints.CENTER;
        labelConstraints.ipady = 10;
        gbl2.setConstraints(atlabel, labelConstraints);
        plotterLabelPanel.add(atlabel);
        add(plotterLabelPanel, BorderLayout.NORTH);
    }

    setPlotter(p);
    add(buttonPanel, BorderLayout.SOUTH);
    repaint();
}
 
Example 6
Source File: HistoryWindow.java    From Spark with Apache License 2.0 5 votes vote down vote up
private Component getMessagesPanel() {
	JPanel panel = new JPanel();
	panel.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();

	c.anchor = GridBagConstraints.CENTER;
	c.fill = GridBagConstraints.BOTH;
	c.gridx = 0;
	c.gridy = 0;
	c.gridwidth = 2;
	c.weightx = 1;
	c.weighty = 1;
	panel.add(historyContentTextScrollPane, c);

	c.anchor = GridBagConstraints.SOUTH;
	c.fill = GridBagConstraints.HORIZONTAL;
	c.gridx = 0;
	c.gridy = 1;
	c.gridwidth = 1;
	c.weightx = 1;
	c.weighty = 0.02;
	c.insets = new Insets(0, 0, 0, 3);
	panel.add(findTextField, c);

	c.gridx = 1;
	c.gridy = 1;
	c.gridwidth = 1;
	c.weightx = 0.1;
	c.insets = new Insets(0, 0, 0, 0);
	panel.add(btnFind, c);
	return panel;
}
 
Example 7
Source File: ChatLounge.java    From megamek with GNU General Public License v2.0 5 votes vote down vote up
public MekInfo() {

            lblImage = new JLabel();
            lblLoad = new JLabel();

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

            c.fill = GridBagConstraints.NONE;
            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;
            c.gridheight = 1;
            c.anchor = GridBagConstraints.CENTER;
            gridbag.setConstraints(lblLoad, c);
            add(lblLoad);

            c.fill = GridBagConstraints.BOTH;
            c.insets = new Insets(1, 1, 1, 1);
            c.gridx = 1;
            c.gridy = 0;
            c.weightx = 1.0;
            c.weighty = 1.0;
            c.gridwidth = 1;
            c.gridheight = 1;
            c.anchor = GridBagConstraints.NORTHWEST;
            gridbag.setConstraints(lblImage, c);
            add(lblImage);

            lblImage.setBorder(BorderFactory.createEmptyBorder());
        }
 
Example 8
Source File: AlertsPanel.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
private void initialize(List<String> alertTypes) {

        selections = new ArrayList<JCheckBox>();
        // Alert selection Panel
        JPanel selectionPanel = new JPanel();
        selectionPanel.setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(2, 5, 30, 10);

        selectionPanel.add(
                getRiskBox(
                        Constant.messages.getString("customreport.alertspanel.risk.high"), "High"),
                gbc);

        gbc.gridx++;
        selectionPanel.add(
                getRiskBox(
                        Constant.messages.getString("customreport.alertspanel.risk.medium"),
                        "Medium"),
                gbc);

        gbc.gridx++;
        selectionPanel.add(
                getRiskBox(Constant.messages.getString("customreport.alertspanel.risk.low"), "Low"),
                gbc);

        gbc.gridx++;
        selectionPanel.add(
                getRiskBox(
                        Constant.messages.getString("customreport.alertspanel.risk.info"),
                        "Informational"),
                gbc);

        gbc.insets = new Insets(0, 20, 2, 0);
        gbc.gridy = 1;
        gbc.gridwidth = 4;

        for (String alertType : alertTypes) {

            JCheckBox selection = new JCheckBox();
            selection.setText(alertType);
            selection.setSelected(true);
            selection.setName(alertType);

            gbc.gridx = 0;
            gbc.anchor = GridBagConstraints.CENTER;
            selectionPanel.add(selection, gbc);
            this.getSelections().add(selection);
            gbc.gridy += 1;
        }

        this.setLayout(new BorderLayout());
        this.add(
                new JLabel(Constant.messages.getString("customreport.alertspanel.label")),
                BorderLayout.NORTH);
        this.add(new JScrollPane(selectionPanel), BorderLayout.CENTER);
    }
 
Example 9
Source File: ServiceDialog.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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);
}
 
Example 10
Source File: PrintLayoutDialog.java    From pumpernickel with MIT License 4 votes vote down vote up
/**
 * Creates a new dialog. It is recommended that you provide the Paintables
 * up front, so you should use the other constructor. But if this is not
 * possible, then this constructor will create a valid dialog. In this case
 * you need to overwrite the print() method: otherwise this dialog has no
 * idea what to print.
 * 
 * @param parent
 *            the parent Frame.
 * @param title
 *            the dialog title.
 * @param layout
 *            the PrintLayout to use.
 *            <P>
 *            This is modified only after 'OK' or 'Print' is selected. At
 *            that point the user's changes are stored in this layout.
 * @param helpURL
 *            an optional URL that will provide a button/link for help in
 *            the lower-left corner of the dialog. This may be null.
 *
 * @throws HeadlessException
 *             if this is invoked in a headless environment.
 */
public PrintLayoutDialog(Frame parent, String title, PrintLayout layout,
		URL helpURL) throws HeadlessException {
	super(parent, title, true);
	originalPrintLayout = layout;
	printLayout = new PrintLayout(layout);
	getContentPane().setLayout(new GridBagLayout());
	propertiesPanel = new PrintLayoutPropertiesPanel(printLayout, true,
			false);
	layoutPreview = new PrintLayoutPreviewPanel(printLayout);
	JButton[] dismissButtons = new JButton[] { printButton, okButton,
			cancelButton };

	JComponent[] leftControls;
	if (helpURL == null) {
		leftControls = new JComponent[] {};
	} else {
		leftControls = new JComponent[] { HelpButton.create(helpURL) };
	}

	footer = new DialogFooter(leftControls, dismissButtons, true,
			dismissButtons[0]);

	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 0;
	c.fill = GridBagConstraints.NONE;
	c.insets = new Insets(10, 10, 10, 10);
	c.gridy++;
	c.fill = GridBagConstraints.BOTH;
	c.weighty = 1;
	getContentPane().add(layoutPreview, c);

	c.gridx++;
	c.fill = GridBagConstraints.NONE;
	c.anchor = GridBagConstraints.WEST;
	c.weightx = 0;
	getContentPane().add(propertiesPanel, c);

	c.gridx = 0;
	c.gridy++;
	c.gridwidth = 2;
	c.weighty = 0;
	c.fill = GridBagConstraints.HORIZONTAL;
	c.insets = new Insets(10, 10, 10, 10);
	c.anchor = GridBagConstraints.CENTER;
	getContentPane().add(footer, c);

	Dimension d = propertiesPanel.getPreferredSize();
	d.width = Math.max(d.width, d.height);
	d.height = Math.max(d.width, d.height);
	layoutPreview.setPreferredSize(d);

	footer.addActionListener(actionListener);

	setResizable(false);

	pack();
}
 
Example 11
Source File: AquaLocationPaneControls.java    From pumpernickel with MIT License 4 votes vote down vote up
public AquaLocationPaneControls(LocationPaneUI paneUI) {
	this.paneUI = paneUI;

	layoutButtons.add(tileView);
	layoutButtons.add(listView);
	// TODO: implement a UI for the column view.
	// layoutButtons.add(columnView);

	ButtonGroup layoutGroup = new ButtonGroup();
	layoutGroup.add(tileView);
	layoutGroup.add(listView);
	layoutGroup.add(columnView);

	layoutButtons.setFloatable(false);

	tileView.addActionListener(controlListener);
	listView.addActionListener(controlListener);
	columnView.addActionListener(controlListener);

	String view = LocationPane.getString(paneUI.getLocationPane(),
			KEY_DEFAULT_VIEW, null);
	if (view == null)
		view = Preferences.userNodeForPackage(getClass()).get("view",
				"tile");
	if (view.equals("list")) {
		listView.doClick();
	} else if (view.equals("column")) {
		columnView.doClick();
	} else {
		tileView.doClick();
	}

	layoutButtons
			.setVisible(LocationPane.getBoolean(paneUI.getLocationPane(),
					KEY_SHOW_VIEW_CONTROLS, Boolean.TRUE));

	BevelButtonUI buttonUI = new BevelButtonUI();
	paneUI.upButton.setUI(buttonUI);
	ButtonCluster.install(layoutButtons, buttonUI, true);
	ButtonCluster.install(paneUI.navigationButtons, buttonUI, true);

	paneUI.navigationButtons.setVisible(LocationPane.getBoolean(
			paneUI.getLocationPane(), KEY_SHOW_FORWARD_BACKWARD_BUTTONS,
			Boolean.TRUE));

	setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.insets = new Insets(0, 0, 0, 0);
	c.weightx = 0;
	c.weighty = 1;
	add(paneUI.navigationButtons, c);
	c.gridx++;
	add(layoutButtons, c);

	c.gridx++;
	c.weightx = 1;
	c.fill = GridBagConstraints.HORIZONTAL;
	c.anchor = GridBagConstraints.CENTER;

	c.insets = new Insets(3, 0, 0, 0);
	add(paneUI.comboBox, c);
	c.insets = new Insets(0, 0, 0, 0);
	c.weightx = 1;
	c.gridx++;
	add(paneUI.searchField, c);
	setBorder(new EmptyBorder(new Insets(0, 5, 0, 5)));

	paneUI.searchField.setVisible(LocationPane.getBoolean(
			paneUI.getLocationPane(), KEY_SHOW_SEARCHBAR, Boolean.TRUE));

	paneUI.nextButton.setRequestFocusEnabled(false);
	paneUI.backButton.setRequestFocusEnabled(false);

	paneUI.searchField.setUI(new RoundTextFieldUI());
	paneUI.searchField.putClientProperty("JTextField.variant", "search");
	@SuppressWarnings("unused")
	TextFieldPrompt prompt = new TextFieldPrompt(paneUI.searchField,
			"search");
}
 
Example 12
Source File: BeltColumnStatisticsPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Updates the charts.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
	for (int i = 0; i < listOfChartPanels.size(); i++) {
		JPanel panel = listOfChartPanels.get(i);
		panel.removeAll();
		JFreeChart chartOrNull = getModel().getChartOrNull(i);
		if (chartOrNull != null) {
			final ChartPanel chartPanel = new ChartPanel(chartOrNull) {

				private static final long serialVersionUID = -6953213567063104487L;

				@Override
				public Dimension getPreferredSize() {
					return DIMENSION_CHART_PANEL_ENLARGED;
				}
			};
			chartPanel.setPopupMenu(null);
			chartPanel.setBackground(COLOR_TRANSPARENT);
			chartPanel.setOpaque(false);
			chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
			panel.add(chartPanel, BorderLayout.CENTER);

			JPanel openChartPanel = new JPanel(new GridBagLayout());
			openChartPanel.setOpaque(false);

			GridBagConstraints gbc = new GridBagConstraints();
			gbc.anchor = GridBagConstraints.CENTER;
			gbc.fill = GridBagConstraints.NONE;
			gbc.weightx = 1.0;
			gbc.weighty = 1.0;

			JButton openChartButton = new JButton(OPEN_CHART_ACTION);
			openChartButton.setOpaque(false);
			openChartButton.setContentAreaFilled(false);
			openChartButton.setBorderPainted(false);
			openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
			openChartButton.setHorizontalAlignment(SwingConstants.LEFT);
			openChartButton.setHorizontalTextPosition(SwingConstants.LEFT);
			openChartButton.setIcon(null);
			Font font = openChartButton.getFont();
			Map attributes = font.getAttributes();
			attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
			openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f));

			openChartPanel.add(openChartButton, gbc);

			panel.add(openChartPanel, BorderLayout.SOUTH);
		}
		panel.revalidate();
		panel.repaint();
	}
}
 
Example 13
Source File: TaskImportDialog.java    From chipster with MIT License 4 votes vote down vote up
public TaskImportDialog(ClientApplication application, String title, ImportSession importSession, Operation importOperation, String okButtonText, String cancelButtonText, String skipButtonText, String noteText) throws MicroarrayException {
	super(Session.getSession().getFrames().getMainFrame(), true);

	this.application = application;
	this.importSession = importSession;
	this.importOperation = importOperation;
	this.setTitle("Import");
	this.setModal(true);
	this.setPreferredSize(new Dimension(500, 300));

	// initialise components
	titleLabel = new JLabel("<html><p style=" + VisualConstants.HTML_DIALOG_TITLE_STYLE + ">" + title + "</p></html>");
	descriptionLabel = new JLabel("<html>" + importOperation.getDescription() + "</html>");
	noteLabel = new JLabel("<html><p style=\"font-style:italic\">" + noteText + "</p></html>");

	folderNameCombo = new JComboBox(ImportUtils.getFolderNames(false).toArray());
	folderNameCombo.setEditable(true);

	okButton = new JButton(okButtonText);
	okButton.setPreferredSize(BUTTON_SIZE);
	okButton.addActionListener(this);

	skipButton = new JButton(skipButtonText);
	skipButton.setPreferredSize(BUTTON_SIZE);
	skipButton.addActionListener(this);

	cancelButton = new JButton(cancelButtonText);
	cancelButton.setPreferredSize(BUTTON_SIZE);
	cancelButton.addActionListener(this);

	ImportParameterPanel parameterPanel = new ImportParameterPanel(importOperation, null);

	JPanel keepButtonsRightPanel = new JPanel(new GridBagLayout());
	GridBagConstraints buttonConstraints = new GridBagConstraints();
	buttonConstraints.weightx = 1.0;
	buttonConstraints.weighty = 1.0;
	buttonConstraints.anchor = GridBagConstraints.EAST;
	buttonConstraints.insets.set(0, 0, 0, 8);
	keepButtonsRightPanel.add(cancelButton, buttonConstraints);
	if (importSession != null) {
		buttonConstraints.anchor = GridBagConstraints.CENTER;		
		keepButtonsRightPanel.add(skipButton, buttonConstraints);
	}
	buttonConstraints.gridx = GridBagConstraints.RELATIVE;
	buttonConstraints.insets.set(0, 0, 0, 0);
	keepButtonsRightPanel.add(okButton, buttonConstraints);
	
	
	// layout
	GridBagConstraints c = new GridBagConstraints();
	this.setLayout(new GridBagLayout());

	// title label
	c.weightx = 1.0;
	c.weighty = 1.0;
	c.fill = GridBagConstraints.HORIZONTAL;
	c.anchor = GridBagConstraints.NORTHWEST;
	c.insets.set(10, 10, 5, 10);
	c.gridx = 0;
	c.gridy = 0;
	this.add(titleLabel, c);

	// description label
	c.gridy++;
	this.add(descriptionLabel, c);
	
	// parameter panel
	c.gridy++;
	c.weighty = 120.0;
	c.fill = GridBagConstraints.BOTH;
	c.anchor = GridBagConstraints.NORTHWEST;
	c.insets.set(0, 10, 10, 10);
	this.add(parameterPanel, c);

	// note
	c.gridy++;
	c.weightx = 1.0;
	c.weighty = 1.0;
	c.insets.set(0, 10, 10, 10);
	c.fill = GridBagConstraints.HORIZONTAL;
	this.add(noteLabel, c);
	
	// buttons
	c.insets.set(10, 10, 10, 10);
	c.anchor = GridBagConstraints.SOUTHEAST;
	c.gridy++;
	c.fill = GridBagConstraints.NONE;
	this.add(keepButtonsRightPanel, c);


	// make visible
	this.pack();
	Session.getSession().getFrames().setLocationRelativeToMainFrame(this);
	this.setVisible(true);
}
 
Example 14
Source File: PlayStoreViewBuilder.java    From raccoon4 with Apache License 2.0 4 votes vote down vote up
@Override
protected JPanel assemble() {
	blankloader = new ImageIcon(new BufferedImage(43, 11,
			BufferedImage.TYPE_INT_ARGB));

	JPanel panel = new JPanel();
	panel.setLayout(new BorderLayout());
	GridBagConstraints gbc = new GridBagConstraints();

	sidebar = new JPanel();
	sidebar.setLayout(new CardLayout());
	sidebar.add(
			new OverviewBuilder().withBorder(BorderFactory.createEtchedBorder())
					.build(globals), WELCOME);
	sidebar.setPreferredSize(new Dimension(450, 700));

	serp = new JPanel();
	serp.setLayout(new CardLayout());
	serp.add(new JPanel(), WELCOME);
	serp.setPreferredSize(new Dimension(550, 700));

	query = new JTextField(20);
	query.setMargin(new Insets(2, 2, 2, 2));

	search = new JButton(Messages.getLocalizer().localize("search"));
	query.addActionListener(this);
	search.addActionListener(this);
	query.requestFocusInWindow();

	JPanel container = new JPanel();
	container.setLayout(new GridBagLayout());

	busy = new JLabel(blankloader);
	busy.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

	gbc.gridx = 0;
	gbc.gridy = 0;
	gbc.fill = GridBagConstraints.NONE;
	gbc.anchor = GridBagConstraints.CENTER;
	gbc.insets = new Insets(0, 30, 0, 30);
	container.add(busy, gbc);

	gbc.gridx = 1;
	gbc.gridy = 0;
	gbc.fill = GridBagConstraints.HORIZONTAL;
	gbc.anchor = GridBagConstraints.CENTER;
	gbc.weightx = 1;
	gbc.insets = new Insets(0, 0, 0, 5);
	container.add(query, gbc);

	gbc.gridx = 2;
	gbc.gridy = 0;
	gbc.fill = GridBagConstraints.NONE;
	gbc.anchor = GridBagConstraints.EAST;
	gbc.weightx = 0;
	gbc.insets = new Insets(0, 0, 0, 0);
	container.add(search, gbc);

	gbc.gridx = 0;
	gbc.gridy = 1;
	gbc.gridwidth = 3;
	gbc.anchor = GridBagConstraints.CENTER;
	gbc.fill = GridBagConstraints.BOTH;
	gbc.insets = new Insets(5, 10, 10, 0);
	container.add(new JSeparator(Separator.HORIZONTAL), gbc);

	gbc.gridx = 0;
	gbc.gridy = 2;
	gbc.gridwidth = 3;
	gbc.anchor = GridBagConstraints.CENTER;
	gbc.fill = GridBagConstraints.BOTH;
	gbc.weightx = 1;
	gbc.weighty = 1;
	gbc.insets = new Insets(10, 10, 0, 0);
	container.add(serp, gbc);

	panel.add(container);
	panel.add(sidebar, BorderLayout.WEST);

	globals.get(PlayManager.class).addPlayListener(this);
	globals.get(BridgeManager.class).addBridgeListener(this);
	globals.get(DatabaseManager.class).get(VariableDao.class)
			.addDataSetListener(new DatasetListenerProxy(this));
	globals.get(DatabaseManager.class).get(PlayProfileDao.class)
			.subscribe(new DatasetListenerProxy(this));

	Focus.on(query);
	return panel;
}
 
Example 15
Source File: Convertor.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
   Convert an OSMMap to a GMLMap.
   @param map The OSMMap to convert.
   @return A new GMLMap.
*/
public GMLMap convert(OSMMap map) {
    GMLMap gmlMap = new GMLMap();

    JFrame frame = new JFrame("OSM to GML converter");
    JPanel main = new JPanel(new BorderLayout());
    JComponent top = Box.createVerticalBox();
    top.add(new JLabel("Converting OSM map with " + map.getRoads().size() + " roads and " + map.getBuildings().size() + " buildings"));
    top.add(new JLabel("Map size: " + (map.getMaxLongitude() - map.getMinLongitude()) + " x " + (map.getMaxLatitude() - map.getMinLatitude())));
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(MARGIN, MARGIN, MARGIN, MARGIN);
    JPanel progress = new JPanel(layout);

    //        Random random = new Random();

    TemporaryMap temp = new TemporaryMap(map);

    List<ConvertStep> steps = new ArrayList<ConvertStep>();
    addStep(new CleanOSMStep(temp), steps, progress, layout, c);
    addStep(new ScanOSMStep(temp), steps, progress, layout, c);
    addStep(new MakeTempObjectsStep(temp), steps, progress, layout, c);
    addStep(new SplitIntersectingEdgesStep(temp), steps, progress, layout, c);
    addStep(new SplitShapesStep(temp), steps, progress, layout, c);
    addStep(new RemoveShapesStep(temp), steps, progress, layout, c);
    addStep(new MergeShapesStep(temp), steps, progress, layout, c);
    addStep(new ComputePassableEdgesStep(temp), steps, progress, layout, c);
    /*
    addStep(new CreateBuildingsStep(temp, ConvertTools.sizeOf1Metre(osmMap), random), steps, progress, layout, c);
    addStep(new CreateEntrancesStep(temp), steps, progress, layout, c);
    addStep(new PruneStep(temp), steps, progress, layout, c);
    */
    addStep(new MakeObjectsStep(temp, gmlMap), steps, progress, layout, c);

    main.add(top);
    main.add(progress);

    frame.setContentPane(main);
    frame.pack();
    frame.setVisible(true);

    for (ConvertStep next : steps) {
        next.doStep();
    }

    return gmlMap;
}
 
Example 16
Source File: ImportFromAbstractDialog.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
public ImportFromAbstractDialog(
        JFrame parent, ExtensionGraphQl caller, String title, String fromFieldLabel) {
    super(parent, true);
    this.setTitle(title);
    this.caller = caller;
    centreDialog();

    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(5, 5, 5, 5);

    JButton buttonImport =
            new JButton(Constant.messages.getString(MESSAGE_PREFIX + "importbutton"));
    buttonImport.addActionListener(
            e -> {
                if (validateUrl(fieldEndpoint) && importDefinition()) {
                    setVisible(false);
                    dispose();
                }
            });
    JButton buttonCancel = new JButton(Constant.messages.getString("all.button.cancel"));
    buttonCancel.addActionListener(
            e -> {
                setVisible(false);
                dispose();
            });

    constraints.gridx = 0;
    constraints.gridy = 0;
    add(new JLabel(fromFieldLabel), constraints);

    constraints.gridx = 1;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    constraints.gridwidth = 3;
    setContextMenu(fieldFrom);
    addFromFields(constraints);

    constraints.weightx = 0;
    constraints.gridwidth = 1;
    constraints.gridx = 0;
    constraints.gridy = 1;
    add(new JLabel(Constant.messages.getString(MESSAGE_PREFIX + "labelendpoint")), constraints);

    constraints.gridx = 1;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    constraints.gridwidth = 3;
    setContextMenu(fieldEndpoint);
    add(fieldEndpoint, constraints);

    constraints.gridwidth = 1;
    constraints.gridx = 2;
    constraints.gridy = 2;
    constraints.anchor = GridBagConstraints.CENTER;
    add(buttonCancel, constraints);
    constraints.gridx = 3;
    constraints.anchor = GridBagConstraints.CENTER;
    add(buttonImport, constraints);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    pack();
    setVisible(true);
}
 
Example 17
Source File: TransformationPanel.java    From 3Dscript with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TransformationPanel(float ax, float ay, float az, float dx, float dy, float dz, float s) {
	super();
	setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();

	angleX = makeNumberfield();
	angleY = makeNumberfield();
	angleZ = makeNumberfield();
	dX = makeNumberfield();
	dY = makeNumberfield();
	dZ = makeNumberfield();
	scale = makeNumberfield();

	c.fill = GridBagConstraints.NONE;
	c.anchor = GridBagConstraints.WEST;
	c.insets = new Insets(2, 2, 2, 2);

	c.gridx = c.gridy = 0;
	c.gridwidth = 2;
	add(new JLabel("Rotation"), c);
	c.gridwidth = 1;
	c.gridy++;
	add(new JLabel("X"), c);
	c.gridy++;
	add(new JLabel("Y"), c);
	c.gridy++;
	add(new JLabel("Z"), c);

	c.gridx = 2;
	c.gridy = 0;
	c.gridwidth = 2;
	add(new JLabel("Translation"), c);
	c.gridwidth = 1;
	c.gridy++;
	add(new JLabel("X"), c);
	c.gridy++;
	add(new JLabel("Y"), c);
	c.gridy++;
	add(new JLabel("Z"), c);

	c.gridx = 4;
	c.gridy = 0;
	c.gridwidth = 2;
	add(new JLabel("Scale"), c);
	c.gridwidth = 1;

	c.insets = new Insets(2, 0, 2, 30);

	c.gridx = 1;
	c.gridy = 1;
	add(angleX, c);
	c.gridy++;
	add(angleY, c);
	c.gridy++;
	add(angleZ, c);

	c.gridx = 3;
	c.gridy = 1;
	add(dX, c);
	c.gridy++;
	add(dY, c);
	c.gridy++;
	add(dZ, c);

	c.gridx = 5;
	c.gridy = 1;
	add(scale, c);

	c.anchor = GridBagConstraints.CENTER;
	c.gridx = 4;
	c.gridy = 2;
	c.gridwidth = 2;
	JButton reset = new JButton("Reset");
	reset.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			fireResetTransformation();
		}
	});
	add(reset, c);

	setTransformation(ax, ay, az, dx, dy, dz, s);
}
 
Example 18
Source File: ImportFromAbstractDialog.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
public ImportFromAbstractDialog(
        JFrame parent, ExtensionOpenApi caller, String title, String fromFieldLabel) {
    super(parent, true);
    this.setTitle(title);
    this.caller = caller;
    centreDialog();

    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(5, 5, 5, 5);

    JButton buttonImport =
            new JButton(Constant.messages.getString(MESSAGE_PREFIX + "importbutton"));
    buttonImport.addActionListener(
            e -> {
                if (validateTargetUrl() && importDefinition()) {
                    setVisible(false);
                    dispose();
                }
            });
    JButton buttonCancel = new JButton(Constant.messages.getString("all.button.cancel"));
    buttonCancel.addActionListener(
            e -> {
                setVisible(false);
                dispose();
            });

    constraints.gridx = 0;
    constraints.gridy = 0;
    add(new JLabel(fromFieldLabel), constraints);

    constraints.gridx = 1;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    constraints.gridwidth = 3;
    setContextMenu(fieldFrom);
    addFromFields(constraints);

    constraints.weightx = 0;
    constraints.gridwidth = 1;
    constraints.gridx = 0;
    constraints.gridy = 1;
    add(new JLabel(Constant.messages.getString(MESSAGE_PREFIX + "labeltarget")), constraints);

    constraints.gridx = 1;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    constraints.gridwidth = 3;
    add(fieldTarget, constraints);

    constraints.gridwidth = 1;
    constraints.gridx = 2;
    constraints.gridy = 2;
    constraints.anchor = GridBagConstraints.CENTER;
    add(buttonCancel, constraints);
    constraints.gridx = 3;
    constraints.anchor = GridBagConstraints.CENTER;
    add(buttonImport, constraints);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    pack();
    setVisible(true);
}
 
Example 19
Source File: Main.java    From testing-cin with MIT License 3 votes vote down vote up
/**
 * 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);
}
 
Example 20
Source File: GridBagPanel.java    From mzmine3 with GNU General Public License v2.0 3 votes vote down vote up
public void addCenter(Component component, int gridx, int gridy, int gridwidth, int gridheight) {

    GridBagConstraints constraints = new GridBagConstraints(gridx, gridy, gridwidth, gridheight, 0,
        0, GridBagConstraints.CENTER, GridBagConstraints.NONE, borderInsets, 0, 0);

    super.add(component);

    layout.setConstraints(component, constraints);
  }