Example usage for java.awt GridBagLayout GridBagLayout

List of usage examples for java.awt GridBagLayout GridBagLayout

Introduction

In this page you can find the example usage for java.awt GridBagLayout GridBagLayout.

Prototype

public GridBagLayout() 

Source Link

Document

Creates a grid bag layout manager.

Usage

From source file:be.tutul.naheulcraft.launcher.auth.LogInForm.java

private void createInterface() {
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = 2;//w  w w . j  ava  2  s .  c o  m
    constraints.gridx = 0;
    constraints.gridy = -1;
    constraints.weightx = 1.0D;

    add(Box.createGlue());

    JLabel usernameLabel = new JLabel("Pseudo : ");
    Font labelFont = usernameLabel.getFont().deriveFont(1);
    Font smalltextFont = usernameLabel.getFont().deriveFont(labelFont.getSize() - 2.0F);

    usernameLabel.setFont(labelFont);
    add(usernameLabel, constraints);
    add(this.usernameField, constraints);

    add(Box.createVerticalStrut(10), constraints);

    JLabel passwordLabel = new JLabel("Mot de passe :");
    passwordLabel.setFont(labelFont);
    add(passwordLabel, constraints);
    add(this.passwordField, constraints);

    JLabel forgotPasswordLabel = new JLabel("(oubli ?)");
    forgotPasswordLabel.setCursor(new Cursor(12));
    forgotPasswordLabel.setFont(smalltextFont);
    forgotPasswordLabel.setHorizontalAlignment(4);
    forgotPasswordLabel.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            try {
                Util.openLink(Variables.lost);
            } catch (Exception e1) {
                LogInForm.this.login.getLauncher().getLogger()
                        .error("Impossible d'ouvrir le lien pour les logins oublis");
                JOptionPane.showMessageDialog(LogInForm.this.login.getLauncher().getPanel(),
                        "Impossible d'ouvrir la page\nRendez-vous sur le site de NaheulCraft pour rcuprer vos identifiants",
                        "Impossible d'ouvrir l'URL", 0);
            }
        }
    });
    add(forgotPasswordLabel, constraints);

    createUserDropdownPanel(labelFont);
    add(this.userDropdownPanel, constraints);

    add(Box.createVerticalStrut(10), constraints);
}

From source file:jmap2gml.ScriptGui.java

/**
 * Formats the window, initializes the JMap2Script object, and sets up all
 * the necessary events.//from www.  j  a  v a2  s  . co  m
 */
public ScriptGui() {
    setTitle("jmap to gml script converter");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    getContentPane().setLayout(new GridBagLayout());

    this.addWindowListener(new WindowListener() {
        @Override
        public void windowOpened(WindowEvent we) {
        }

        @Override
        public void windowClosing(WindowEvent we) {
            saveConfig();
        }

        @Override
        public void windowClosed(WindowEvent we) {
        }

        @Override
        public void windowIconified(WindowEvent we) {
        }

        @Override
        public void windowDeiconified(WindowEvent we) {
        }

        @Override
        public void windowActivated(WindowEvent we) {
        }

        @Override
        public void windowDeactivated(WindowEvent we) {
        }
    });

    GridBagConstraints c = new GridBagConstraints();

    setResizable(true);
    setIconImage((new ImageIcon("spikeup.png")).getImage());

    jta = new JTextArea(38, 30);

    loadConfig();

    JScrollPane jsp = new JScrollPane(jta);
    jsp.setRowHeaderView(new TextLineNumber(jta));
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    jsp.setSize(jsp.getWidth(), 608);

    // menu bar
    JMenuBar menubar = new JMenuBar();

    // file menu
    JMenu file = new JMenu("File");

    // load button
    JMenuItem load = new JMenuItem("Load jmap");
    load.addActionListener(ae -> {
        JFileChooser fileChooser = new JFileChooser(prevDirectory);
        fileChooser.setFileFilter(new FileNameExtensionFilter("jmap file", "jmap", "jmap"));

        int returnValue = fileChooser.showOpenDialog(null);

        if (returnValue == JFileChooser.APPROVE_OPTION) {
            File selectedFile = fileChooser.getSelectedFile();

            prevDirectory = selectedFile.getAbsolutePath();

            jm2s = new ScriptFromJmap(selectedFile.getPath(), false);

            jta.setText("");
            jta.append(jm2s.toString());
            jta.setCaretPosition(0);

            writeFile.setEnabled(true);

            drawPanel.setItems(jta.getText().split("\n"));
        }
    });

    // add load to file menu
    file.add(load);

    // button to save script to file
    writeFile = new JMenuItem("Write file");
    writeFile.addActionListener(ae -> {
        if (jm2s != null) {
            PrintWriter out;
            try {
                File f = new File(
                        jm2s.getFileName().substring(0, jm2s.getFileName().lastIndexOf(".jmap")) + ".gml");
                out = new PrintWriter(f);
                out.append(jm2s.toString());
                out.close();
            } catch (FileNotFoundException ex) {
                Logger.getLogger(ScriptGui.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    writeFile.setEnabled(false);

    JMenuItem gmx = new JMenuItem("Export as gmx");
    gmx.addActionListener(ae -> {
        String fn = String.format("%s.room.gmx", prevDirectory);

        JFileChooser fc = new JFileChooser(prevDirectory);
        fc.setSelectedFile(new File(fn));
        fc.setFileFilter(new FileNameExtensionFilter("Game Maker XML", "gmx", "gmx"));
        fc.showDialog(null, "Save");
        File f = fc.getSelectedFile();

        if (f != null) {
            try {
                GMX.itemsToGMX(drawPanel.items, new FileOutputStream(f));
            } catch (FileNotFoundException ex) {
                Logger.getLogger(ScriptGui.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });

    // add to file menu
    file.add(writeFile);
    file.add(gmx);

    // add file menu to the menubar
    menubar.add(file);

    // Edit menu

    // display menu
    JMenu display = new JMenu("Display");

    JMenuItem update = new JMenuItem("Update");

    update.addActionListener(ae -> {
        drawPanel.setItems(jta.getText().split("\n"));
    });

    display.add(update);

    JMenuItem gridToggle = new JMenuItem("Toggle Grid");
    gridToggle.addActionListener(ae -> {
        drawPanel.toggleGrid();
    });
    display.add(gridToggle);

    JMenuItem gridOptions = new JMenuItem("Modify Grid");
    gridOptions.addActionListener(ae -> {
        drawPanel.modifyGrid();
    });
    display.add(gridOptions);

    menubar.add(display);

    // sets the menubar
    setJMenuBar(menubar);

    // add the text area to the window
    c.gridx = 0;
    c.gridy = 0;
    add(jsp, c);

    // initialize the preview panel
    drawPanel = new Preview(this);
    JScrollPane scrollPane = new JScrollPane(drawPanel);

    // add preview panel to the window
    c.gridx = 1;
    c.gridwidth = 2;
    add(scrollPane, c);

    pack();
    setMinimumSize(this.getSize());
    setLocationRelativeTo(null);
    setVisible(true);
    drawPanel.setItems(jta.getText().split("\n"));
}

From source file:EditorPaneExample9.java

public EditorPaneExample9() {
    super("JEditorPane Example 9");
    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;/*from www  . ja  v  a  2s  .c om*/
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    textField = new JTextField(32);
    panel.add(textField, c);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String url = textField.getText();

            try {
                // Check if the new page and the old
                // page are the same.
                URL newURL = new URL(url);
                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(newURL)) {
                    return;
                }

                // Try to display the page
                textField.setEnabled(false); // Disable input
                textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

                timeLabel.setText("");
                timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

                startTime = System.currentTimeMillis();

                // Choose the loading method
                if (onlineLoad.isSelected()) {
                    // Usual load via setPage
                    pane.setPage(url);
                    loadedType.setText(pane.getContentType());
                } else {
                    pane.setContentType("text/html");
                    loadedType.setText(pane.getContentType());
                    if (loader == null) {
                        loader = new HTMLDocumentLoader();
                    }
                    HTMLDocument doc = loader.loadDocument(new URL(url));
                    loadComplete();
                    pane.setDocument(doc);
                    displayLoadTime();
                }
            } catch (Exception e) {
                System.out.println(e);
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                textField.setEnabled(true);
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
            }
        }
    });
}

From source file:com.github.pemapmodder.pocketminegui.gui.server.ConsolePanel.java

public ConsolePanel(ServerMainActivity activity) {
    this.activity = activity;
    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(20, 10, 20, 10));
    title = new JLabel("PocketMine-MP");
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.CENTER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weighty = 0.1;//from  w ww.  j a  va 2 s.  c o m
    add(title, c);
    stdout = new JEditorPane();
    stdout.setContentType("text/html");
    stdout.setText("<html><body style='font-family: monospace; color: #FFFFFF;'><p id='p'></p></body></html>");
    doc = (HTMLDocument) stdout.getDocument();
    para = doc.getElement("p");
    //      stdout.setEditable(false);
    // People NEED to see this to feel happy
    stdout.setForeground(Color.WHITE);
    stdout.setBackground(Color.BLACK);
    Style style = doc.getStyleSheet().addStyle(null, null);
    //      style.addAttribute(StyleConstants.Foreground, Color.WHITE);
    //      style.addAttribute(StyleConstants.Background, Color.RED);
    doc.setParagraphAttributes(para.getStartOffset(), 1, style, true);
    stdout.setBorder(BorderFactory.createDashedBorder(new Color(0x80, 0x80, 0x80)));
    c.gridy = 1;
    c.weightx = 0.9;
    c.weighty = 0.9;
    c.weighty = 0.6;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.NORTH;
    add(stdout, c);
    Timer timer = new Timer(50, e -> updateConsole());
    timer.start();
}

From source file:cz.alej.michalik.totp.client.OtpPanel.java

/**
 * Pid jeden panel se zznamem/*w  w  w.j  av  a2 s.c om*/
 * 
 * @param raw_data
 *            Data z Properties
 * @param p
 *            Properties
 * @param index
 *            Index zznamu - pro vymazn
 */
public OtpPanel(String raw_data, final Properties p, final int index) {
    // Data jsou oddlena stednkem
    final String[] data = raw_data.split(";");

    // this.setBackground(App.COLOR);
    this.setLayout(new GridBagLayout());
    // Mkov rozloen prvk
    GridBagConstraints c = new GridBagConstraints();
    this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 100));

    // Tla?tko pro zkoprovn hesla
    final JButton passPanel = new JButton("");
    passPanel.setFont(passPanel.getFont().deriveFont(App.FONT_SIZE));
    passPanel.setBackground(App.COLOR);
    // Zabere celou ku
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 100;
    this.add(passPanel, c);
    passPanel.setText(data[0]);

    // Tla?tko pro smazn
    JButton delete = new JButton("X");
    try {
        String path = "/material-design-icons/action/drawable-xhdpi/ic_delete_black_24dp.png";
        Image img = ImageIO.read(App.class.getResource(path));
        delete.setIcon(new ImageIcon(img));
        delete.setText("");
    } catch (Exception e) {
        System.out.println("Icon not found");
    }
    delete.setFont(delete.getFont().deriveFont(App.FONT_SIZE));
    delete.setBackground(App.COLOR);
    // Zabere kousek vpravo
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.5;
    c.anchor = GridBagConstraints.EAST;
    this.add(delete, c);

    // Akce pro vytvoen a zkoprovn hesla do schrnky
    passPanel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("Generuji kod pro " + data[1]);
            System.out.println(new Base32().decode(data[1].getBytes()).length);
            clip.set(new TOTP(new Base32().decode(data[1].getBytes())).toString());
            System.out.printf("Kd pro %s je ve schrnce\n", data[0]);
            passPanel.setText("Zkoprovno");
            // Zobraz zprvu na 1 vteinu
            int time = 1000;
            // Animace zobrazen zprvy po zkoprovn
            final Timer t = new Timer(time, new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    passPanel.setText(data[0]);
                }
            });
            t.start();
            t.setRepeats(false);
        }
    });

    // Akce pro smazn panelu a uloen zmn
    delete.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.printf("Odstrann %s s indexem %d\n", data[0], index);
            p.remove(String.valueOf(index));
            App.saveProperties();
            App.loadProperties();
        }
    });

}

From source file:misc.ShapedWindowDemo.java

public ShapedWindowDemo() {
    super("ShapedWindow");
    setLayout(new GridBagLayout());

    // It is best practice to set the window's shape in
    // the componentResized method.  Then, if the window
    // changes size, the shape will be correctly recalculated.
    addComponentListener(new ComponentAdapter() {
        // Give the window an elliptical shape.
        // If the window is resized, the shape is recalculated here.
        @Override//from w ww . j a  va 2s.  c  o  m
        public void componentResized(ComponentEvent e) {
            setShape(new Ellipse2D.Double(0, 0, getWidth(), getHeight()));
        }
    });

    setUndecorated(true);
    setSize(300, 200);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    add(new JButton("I am a Button"));
}

From source file:rhinova.gui.dataentry.link.LinkDataEditPannel.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    label1 = new JLabel();
    label2 = new JLabel();
    lblId = new JLabel();
    label3 = new JLabel();
    txtName = new JTextField();
    label8 = new JLabel();
    txtCapacity = new JTextField();
    label4 = new JLabel();
    txtSurvivalRate = new JTextField();
    label5 = new JLabel();
    comboReserve1 = new JComboBox<>();
    label6 = new JLabel();
    comboReserve2 = new JComboBox<>();

    //======== this ========
    setLayout(new GridBagLayout());
    ((GridBagLayout) getLayout()).columnWidths = new int[] { 54, 0, 0 };
    ((GridBagLayout) getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
    ((GridBagLayout) getLayout()).columnWeights = new double[] { 0.0, 0.0, 1.0E-4 };
    ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 };

    //---- label1 ----
    label1.setText("Link Properties");
    label1.setFont(new Font("Tahoma", Font.PLAIN, 16));
    add(label1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 15, 0), 0, 0));

    //---- label2 ----
    label2.setText("id");
    add(label2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(lblId, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 15, 0), 0, 0));

    //---- label3 ----
    label3.setText("name");
    add(label3, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(txtName, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0));

    //---- label8 ----
    label8.setText("capacity");
    add(label8, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(txtCapacity, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0));

    //---- label4 ----
    label4.setText("survival rate");
    add(label4, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(txtSurvivalRate, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0));

    //---- label5 ----
    label5.setText("reserve 1");
    add(label5, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(comboReserve1, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0));

    //---- label6 ----
    label6.setText("reserve 2");
    add(label6, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 15), 0, 0));
    add(comboReserve2, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:components.TextDemo.java

public TextDemo() {
    super(new GridBagLayout());

    textField = new JTextField(20);
    textField.addActionListener(this);

    textArea = new JTextArea(5, 20);
    textArea.setEditable(false);/*from   www  . j a va2s . c  om*/
    JScrollPane scrollPane = new JScrollPane(textArea);

    //Add Components to this panel.
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = GridBagConstraints.REMAINDER;

    c.fill = GridBagConstraints.HORIZONTAL;
    add(textField, c);

    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    add(scrollPane, c);
}

From source file:com.digitalgeneralists.assurance.ui.components.AboutPanel.java

protected void initializeComponent() {
    if (!this.initialized) {
        GridBagLayout gridbag = new GridBagLayout();
        setLayout(gridbag);/*from   w  w  w  . j  a  v a2s  .c  o  m*/

        GridBagConstraints applicationIconConstraints = new GridBagConstraints();
        applicationIconConstraints.anchor = 11;
        applicationIconConstraints.fill = 1;
        applicationIconConstraints.gridx = 0;
        applicationIconConstraints.gridy = 0;
        applicationIconConstraints.weightx = 1.0D;
        applicationIconConstraints.weighty = 0.8D;
        applicationIconConstraints.gridheight = 1;
        applicationIconConstraints.gridwidth = 1;
        applicationIconConstraints.insets = new Insets(5, 5, 5, 5);
        try {
            Image iconImage = ImageIO.read(getClass().getClassLoader().getResource("assurance.png"));
            iconImage = iconImage.getScaledInstance(48, 48, 0);
            JLabel applicationIcon = new JLabel(new ImageIcon(iconImage));
            add(applicationIcon, applicationIconConstraints);
        } catch (IOException e) {
            this.logger.warn(e);
        }

        GridBagConstraints applicationNameLabelConstraints = new GridBagConstraints();
        applicationNameLabelConstraints.anchor = 11;
        applicationNameLabelConstraints.fill = 1;
        applicationNameLabelConstraints.gridx = 0;
        applicationNameLabelConstraints.gridy = 1;
        applicationNameLabelConstraints.weightx = 1.0D;
        applicationNameLabelConstraints.weighty = 0.1D;
        applicationNameLabelConstraints.gridheight = 1;
        applicationNameLabelConstraints.gridwidth = 1;
        applicationNameLabelConstraints.insets = new Insets(5, 5, 5, 5);

        JLabel applicationNameLabel = new JLabel(Application.applicationName, 0);
        add(applicationNameLabel, applicationNameLabelConstraints);

        GridBagConstraints applicationVersionLabelConstraints = new GridBagConstraints();
        applicationVersionLabelConstraints.anchor = 11;
        applicationVersionLabelConstraints.fill = 1;
        applicationVersionLabelConstraints.gridx = 0;
        applicationVersionLabelConstraints.gridy = 2;
        applicationVersionLabelConstraints.weightx = 1.0D;
        applicationVersionLabelConstraints.weighty = 0.1D;
        applicationVersionLabelConstraints.gridheight = 1;
        applicationVersionLabelConstraints.gridwidth = 1;
        applicationVersionLabelConstraints.insets = new Insets(5, 5, 5, 5);

        StringBuilder labelText = new StringBuilder(128);
        JLabel applicationVersionLabel = new JLabel(labelText.append(Application.applicationVersion)
                .append(" (").append(Application.applicationBuildNumber).append(")").toString(), 0);
        labelText.setLength(0);

        add(applicationVersionLabel, applicationVersionLabelConstraints);

        this.initialized = true;
    }
}

From source file:de.fhg.iais.asc.ui.components.panel.LeftLabeledElementJPanel.java

public LeftLabeledElementJPanel(String prefix) {
    super(new GridBagLayout());

    this.prefix = (StringUtils.isEmpty(prefix)) ? "" : (prefix + ".");

    this.cLabel.gridx = 0;
    this.cLabel.gridy = 0;
    this.cLabel.weightx = WEIGHTX_LABEL;
    this.cLabel.fill = GridBagConstraints.HORIZONTAL;

    this.cElement.gridx = 1;
    this.cElement.gridwidth = 2;
    this.cElement.gridy = 0;
    this.cElement.weightx = WEIGHTX_ELEMENT;
    this.cElement.fill = GridBagConstraints.HORIZONTAL;
}