Example usage for java.awt GridBagConstraints NONE

List of usage examples for java.awt GridBagConstraints NONE

Introduction

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

Prototype

int NONE

To view the source code for java.awt GridBagConstraints NONE.

Click Source Link

Document

Do not resize the component.

Usage

From source file:org.openconcerto.erp.core.finance.accounting.ui.ClotureMensuellePayePanel.java

public ClotureMensuellePayePanel() {

    super();/*from ww w  .  j a  v  a 2  s . com*/

    this.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(2, 2, 1, 2);
    c.weightx = 0;
    c.weighty = 0;
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 0;
    c.gridy = 0;

    JLabel labelMois = new JLabel("Cloture du mois de ");
    this.add(labelMois, c);

    final ElementComboBox selMois = new ElementComboBox(true, 25);
    selMois.init(((ComptaPropsConfiguration) Configuration.getInstance()).getDirectory()
            .getElement(MoisSQLElement.class));
    selMois.setButtonsVisible(false);
    c.gridx++;
    this.add(selMois, c);

    JLabel labelAnnee = new JLabel("Anne");
    c.gridx++;
    this.add(labelAnnee, c);
    final JTextField textAnnee = new JTextField(5);
    c.gridx++;
    this.add(textAnnee, c);
    DateFormat format = new SimpleDateFormat("yyyy");
    textAnnee.setText(format.format(new Date()));

    c.gridy++;
    c.gridx = 0;
    final JCheckBox boxValid = new JCheckBox("Valider toutes les payes du mois");
    final JCheckBox boxCompta = new JCheckBox("Gnrer les critures comptables associes");
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(boxValid, c);
    boxValid.setSelected(true);
    c.gridy++;
    this.add(boxCompta, c);

    JButton buttonClot = new JButton("Clturer");
    JButton buttonFermer = new JButton("Fermer");

    JPanel panelButton = new JPanel();
    panelButton.add(buttonClot);
    panelButton.add(buttonFermer);
    c.anchor = GridBagConstraints.SOUTHEAST;
    c.fill = GridBagConstraints.NONE;
    c.weighty = 1;
    c.gridy++;
    this.add(panelButton, c);

    buttonFermer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ((JFrame) SwingUtilities.getRoot(ClotureMensuellePayePanel.this)).dispose();
        }
    });

    buttonClot.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {

                // Valider les fiches non valids des salaris actifs
                if (boxValid.isSelected()) {
                    SQLSelect selFiche = new SQLSelect();
                    SQLTable tableFiche = ClotureMensuellePayePanel.this.base.getTable("FICHE_PAYE");
                    SQLTable tableSalarie = ClotureMensuellePayePanel.this.base.getTable("SALARIE");
                    SQLTable tableInfosSal = ClotureMensuellePayePanel.this.base.getTable("INFOS_SALARIE_PAYE");
                    selFiche.addSelect(tableFiche.getField("ID"));

                    selFiche.setWhere(new Where(tableFiche.getField("VALIDE"), "=", Boolean.FALSE));
                    selFiche.andWhere(new Where(tableFiche.getField("ID_MOIS"), "=", selMois.getSelectedId()));
                    selFiche.andWhere(
                            new Where(tableFiche.getField("ANNEE"), "=", new Integer(textAnnee.getText())));
                    selFiche.andWhere(
                            new Where(tableSalarie.getField("ID"), "=", tableFiche.getField("ID_SALARIE")));
                    selFiche.andWhere(new Where(tableInfosSal.getField("ID"), "=",
                            tableSalarie.getField("ID_INFOS_SALARIE_PAYE")));

                    // FIXME ne pas valider les fiches d'un employ renvoy

                    // Where w2 = new Where(tableInfosSal.getField("DATE_SORTIE"), "IS",
                    // "NULL");
                    Calendar cal = Calendar.getInstance();
                    cal.set(Calendar.DATE, 1);
                    cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
                    cal.set(Calendar.YEAR, Integer.parseInt(textAnnee.getText()));
                    cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE));

                    Where w = new Where(tableInfosSal.getField("DATE_SORTIE"), "<=", cal.getTime());
                    w = w.or(new Where(tableInfosSal.getField("DATE_SORTIE"), "=", (Object) null));
                    selFiche.andWhere(w);
                    String req = selFiche.asString();
                    System.err.println(req);
                    List l = (List) ClotureMensuellePayePanel.this.base.getDataSource().execute(req,
                            new ArrayListHandler());

                    for (int i = 0; i < l.size(); i++) {

                        Object[] tmp = (Object[]) l.get(i);
                        SQLRow rowFicheTmp = tableFiche.getRow(Integer.parseInt(tmp[0].toString()));
                        System.err.println(rowFicheTmp);
                        FichePayeSQLElement.validationFiche(rowFicheTmp.getID());
                    }
                }

                // cloture du mois et generation compta

                SQLSelect selFiche = new SQLSelect(ClotureMensuellePayePanel.this.base);
                SQLTable tableFiche = ClotureMensuellePayePanel.this.base.getTable("FICHE_PAYE");
                SQLTable tableMois = ClotureMensuellePayePanel.this.base.getTable("MOIS");
                selFiche.addSelect(tableFiche.getField("ID"));

                selFiche.setWhere(new Where(tableFiche.getField("VALIDE"), "=", Boolean.TRUE));
                selFiche.andWhere(new Where(tableFiche.getField("ID_MOIS"), "=", selMois.getSelectedId()));
                selFiche.andWhere(
                        new Where(tableFiche.getField("ANNEE"), "=", new Integer(textAnnee.getText())));

                String req = selFiche.asString();

                List l = (List) ClotureMensuellePayePanel.this.base.getDataSource().execute(req,
                        new ArrayListHandler());

                if (l != null && l.size() > 0) {
                    int[] idS = new int[l.size()];
                    SQLRow rowMois = tableMois.getRow(selMois.getSelectedId());

                    for (int i = 0; i < l.size(); i++) {

                        Object[] tmp = (Object[]) l.get(i);
                        idS[i] = Integer.parseInt(tmp[0].toString());
                        SQLRow rowFiche = tableFiche.getRow(idS[i]);
                        FichePayeSQLElement.clotureMensuelle(selMois.getSelectedId(),
                                Integer.parseInt(textAnnee.getText()), rowFiche.getInt("ID_SALARIE"));
                    }
                    if (boxCompta.isSelected()) {
                        new GenerationMvtFichePaye(idS, rowMois.getString("NOM"), textAnnee.getText());
                    }
                }
                System.err.println(
                        "ClotureMensuellePayePanel.ClotureMensuellePayePanel().new ActionListener() {...}.actionPerformed()");
                JOptionPane.showMessageDialog(null, "Clture termine");
            } catch (Exception ex) {
                ExceptionHandler.handle("Unable to complete operation", ex);
            }
        }
    });
}

From source file:ro.nextreports.designer.wizpublish.PublishLoginWizardPanel.java

private void init() {

    userTextField = new JTextField();

    passField = new JPasswordField();
    rememberCheckBox = new JCheckBox(I18NSupport.getString("wizard.publish.login.remember"));

    ServerHandler serverHandler = new ServerHandler();
    List<Server> servers = serverHandler.getServers();
    String lastServer = ReporterPreferencesManager.getInstance()
            .loadParameter(ReporterPreferencesManager.LAST_SERVER);
    if (lastServer != null) {
        serverHandler.adjustServers(lastServer);
        autoSetCredentials(lastServer);//from   ww  w . j av a2s.c om
    }

    serverPanel = new ServerSelectionPanel(serverHandler) {

        @Override
        public void selection() {
            Server server = getServer();
            if (server != null) {
                autoSetCredentials(server.getName());
            }
        }
    };

    // edit from server (url protocol contains user name)
    if (Globals.getServerUser() != null) {
        userTextField.setText(Globals.getServerUser());
        userTextField.setEnabled(false);

        serverPanel.setServerRequest(Globals.getServerUrl());
    }

    setLayout(new GridBagLayout());
    add(new JLabel(I18NSupport.getString("wizard.publish.login.server")), new GridBagConstraints(0, 0, 1, 1,
            0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    add(serverPanel, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    add(new JLabel(I18NSupport.getString("wizard.publish.login.user")), new GridBagConstraints(0, 1, 1, 1, 0.0,
            0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    add(userTextField, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    add(new JLabel(I18NSupport.getString("wizard.publish.login.password")), new GridBagConstraints(0, 2, 1, 1,
            0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    add(passField, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    add(rememberCheckBox, new GridBagConstraints(1, 3, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

    add(new JLabel(""), new GridBagConstraints(0, 4, 3, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
}

From source file:net.chaosserver.timelord.swingui.SummaryPanel.java

/**
 * Constructs the panel.//from  w  w  w  .java  2  s  . co m
 */
protected void buildSummaryPanel() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    setLayout(gridBagLayout);

    if (isToday()) {
        JLabel remainderName = new JLabel("Remainder");
        gridBagConstraints.anchor = GridBagConstraints.SOUTHWEST;
        gridBagConstraints.weightx = LayoutConstants.HEAVY_WEIGHT;
        gridBagConstraints.insets = new Insets(0, LayoutConstants.SMALL_INSET, 0, LayoutConstants.BIG_INSET);
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.gridwidth = 1;
        gridBagLayout.addLayoutComponent(remainderName, gridBagConstraints);
        add(remainderName);

        timeLeftLabel = new JLabel();
        gridBagConstraints.anchor = GridBagConstraints.SOUTHEAST;
        gridBagConstraints.fill = GridBagConstraints.NONE;
        gridBagConstraints.weightx = 0;
        gridBagConstraints.insets = new Insets(0, LayoutConstants.BIG_INSET, 0, LayoutConstants.SMALL_INSET);
        gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
        gridBagLayout.addLayoutComponent(timeLeftLabel, gridBagConstraints);
        add(timeLeftLabel);
    }

    JLabel taskName = new JLabel("Total");
    gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = LayoutConstants.HEAVY_WEIGHT;
    gridBagConstraints.insets = new Insets(0, LayoutConstants.SMALL_INSET, 0, LayoutConstants.BIG_INSET);
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.gridwidth = 1;
    gridBagLayout.addLayoutComponent(taskName, gridBagConstraints);
    add(taskName);

    totalTimeLabel = new JLabel();
    gridBagConstraints.anchor = GridBagConstraints.NORTHEAST;
    gridBagConstraints.fill = GridBagConstraints.NONE;
    gridBagConstraints.weightx = 0;
    gridBagConstraints.insets = new Insets(0, LayoutConstants.BIG_INSET, 0, LayoutConstants.SMALL_INSET);
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.addLayoutComponent(totalTimeLabel, gridBagConstraints);
    add(totalTimeLabel);

    updateTotalTimeLabel();
    updateTimeLeftLabel();
}

From source file:org.n52.oxf.ui.swing.ChartDialog.java

/**
 * This method initializes this/*from  ww  w .j  a v  a 2 s  .c  om*/
 * 
 * @return void
 */
private void initialize() {
    this.setSize(dialogWidth, dialogHeight);

    MyGridBagLayout mainLayout = new MyGridBagLayout(this.getContentPane());

    this.getContentPane().setLayout(mainLayout);

    mainLayout.addComponent(0, timePeriodPanel, 0, 1, 1, 1, 10, 10, GridBagConstraints.EAST,
            GridBagConstraints.NONE, new Insets(2, 2, 2, 2));

    mainLayout.addComponent(1, applyButton, 0, 2, 2, 1, 100, 10, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0));

    mainLayout.addComponent(2, nowButton, 1, 1, 1, 1, 10, 10, GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(32, 0, 0, 0));
}

From source file:org.executequery.gui.editor.ManageShortcutsPanel.java

private void init() {

    createTextPane();//from w  w  w.  j  a  v  a2  s . c  o  m
    createList();

    JSplitPane splitPane = createSplitPane();
    splitPane.setLeftComponent(new JScrollPane(list));
    splitPane.setRightComponent(new JScrollPane(textPane));

    JPanel panel = new JPanel(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.gridy = 0;
    gbc.gridx = 1;
    gbc.insets.top = 5;
    gbc.insets.left = 5;
    gbc.insets.right = 5;
    panel.add(labelForKey("shortcuts"), gbc);
    gbc.gridy++;
    gbc.insets.bottom = 5;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    panel.add(splitPane, gbc);
    gbc.gridx = 0;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.insets.left = 5;
    gbc.insets.right = 0;
    gbc.fill = GridBagConstraints.NONE;
    panel.add(createMoveButtonsPanel(), gbc);

    addActionButton(createSaveButton());
    addActionButton(createCancelButton());

    addContentPanel(panel);

    setPreferredSize(new Dimension(600, 350));
}

From source file:org.rdv.ui.RBNBConnectionDialog.java

public RBNBConnectionDialog(JFrame owner, RBNBController rbnbController, DataPanelManager dataPanelManager) {
    super(owner, true);

    this.rbnb = rbnbController;
    this.dataPanelManager = dataPanelManager;

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setTitle("Connect to RBNB Server");

    JPanel container = new JPanel();
    setContentPane(container);/*from  w w  w.java2s  .  c  o m*/

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    headerLabel = new JLabel("Please specify the RBNB server connection information.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    c.gridwidth = 1;

    rbnbHostNameLabel = new JLabel("Host:");
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new Insets(10, 10, 10, 5);
    container.add(rbnbHostNameLabel, c);

    rbnbHostNameTextField = new JTextField(25);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(10, 0, 10, 10);
    container.add(rbnbHostNameTextField, c);

    rbnbPortLabel = new JLabel("Port:");
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new Insets(0, 10, 10, 5);
    container.add(rbnbPortLabel, c);

    rbnbPortTextField = new JTextField();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(0, 0, 10, 10);
    rbnbPortTextField.addFocusListener(new FocusListener() {
        public void focusGained(FocusEvent focusEvent) {
            rbnbPortTextField.setSelectionStart(0);
            rbnbPortTextField.setSelectionEnd(rbnbPortTextField.getText().length());
        }

        public void focusLost(FocusEvent focusEvent) {
        }
    });
    container.add(rbnbPortTextField, c);

    JPanel buttonPanel = new JPanel();

    Action connectAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = 5814028508027064335L;

        public void actionPerformed(ActionEvent e) {
            connect();
        }
    };
    connectAction.putValue(Action.NAME, "Connect");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "connect");
    actionMap.put("connect", connectAction);
    connectButton = new JButton(connectAction);
    buttonPanel.add(connectButton);

    Action cancelAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -679192362775669088L;

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    buttonPanel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(0, 10, 10, 5);
    container.add(buttonPanel, c);

    pack();
    setLocationByPlatform(true);
    setVisible(true);
}

From source file:com.github.cmisbox.ui.BaseFrame.java

public BaseFrame() {
    super(AWTUtilitiesWrapper.isTranslucencyCapable(BaseFrame.gc) ? BaseFrame.gc : null);
    this.log = LogFactory.getLog(this.getClass());

    this.gradient = false;
    this.setUndecorated(true);
    this.mainPanel = new JPanel(new GridBagLayout()) {

        private static final long serialVersionUID = 1035974033526970010L;

        protected void paintComponent(Graphics g) {
            if ((g instanceof Graphics2D) && BaseFrame.this.gradient) {
                final int R = 0;
                final int G = 0;
                final int B = 0;

                Paint p = new GradientPaint(0.0f, 0.0f, new Color(R, G, B, 192), this.getWidth(),
                        this.getHeight(), new Color(R, G, B, 255), true);
                Graphics2D g2d = (Graphics2D) g;
                g2d.setPaint(p);//  ww  w  .  j  ava2 s.c  o m
                g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
            } else {
                super.paintComponent(g);
            }
        }
    };

    this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

    GridBagConstraints gbc = new GridBagConstraints();

    this.mainPanel.setDoubleBuffered(false);
    this.mainPanel.setOpaque(false);
    this.mainPanel.setBorder(BorderFactory.createLineBorder(Color.white));

    JLabel title = new JLabel(this.getWindowTitle(), SwingConstants.CENTER);
    title.setForeground(Color.white);

    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 100;

    this.mainPanel.add(title, gbc);

    Image closeImg = this.getImage("images/application-exit.png", 32, 32);
    JLabel close = new JLabel(new ImageIcon(closeImg), SwingConstants.RIGHT);

    gbc.fill = GridBagConstraints.NONE;
    gbc.gridx = 2;
    gbc.weightx = 0;

    this.mainPanel.add(close, gbc);

    close.addMouseListener(this.closeAdapter);

    this.getContentPane().add(this.mainPanel, BorderLayout.CENTER);

    this.initComponents();

    this.pack();

    this.mainPanel.setOpaque(!this.gradient);
    if (!this.gradient) {
        this.mainPanel.setBackground(new Color(0, 0, 0, 208));
    }

    this.setLocationRelativeTo(null);
    AWTUtilitiesWrapper.setWindowOpaque(this, false);
    this.setVisible(true);
    this.setAlwaysOnTop(true);

}

From source file:org.rdv.ui.LoginDialog.java

public LoginDialog(JFrame owner) {
    super(owner, true);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setTitle("Login to NEES");

    JPanel container = new JPanel();
    setContentPane(container);//from  w  ww .  java 2  s .  c om

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    headerLabel = new JLabel("Please specify your NEES account information.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    errorLabel = new JLabel();
    errorLabel.setVisible(false);
    errorLabel.setForeground(Color.RED);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.insets = new Insets(10, 10, 0, 10);
    container.add(errorLabel, c);

    c.gridwidth = 1;

    userNameLabel = new JLabel("Username:");
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new Insets(10, 10, 10, 5);
    container.add(userNameLabel, c);

    userNameTextField = new JTextField("", 25);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(10, 0, 10, 10);
    container.add(userNameTextField, c);

    userPasswordLabel = new JLabel("Password:");
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new Insets(0, 10, 10, 5);
    container.add(userPasswordLabel, c);

    userPasswordField = new JPasswordField(16);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 3;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(0, 0, 10, 10);
    container.add(userPasswordField, c);

    JPanel buttonPanel = new JPanel();

    Action loginAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -5591044023056646223L;

        public void actionPerformed(ActionEvent e) {
            login();
        }
    };
    loginAction.putValue(Action.NAME, "Login");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "login");
    actionMap.put("login", loginAction);
    loginButton = new JButton(loginAction);
    buttonPanel.add(loginButton);

    Action cancelAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = 6237115705468556255L;

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    buttonPanel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(0, 10, 10, 5);
    container.add(buttonPanel, c);

    pack();
    setLocationByPlatform(true);
    setVisible(true);
}

From source file:de.codesourcery.jasm16.ide.ui.views.ProjectConfigurationView.java

@Override
protected JPanel getPanel() {
    final JPanel result = new JPanel();
    result.setLayout(new GridBagLayout());

    // project name
    int y = 0;/*w w  w  .  jav a  2  s . c o  m*/
    GridBagConstraints cnstrs = constraints(0, y, false, false, GridBagConstraints.NONE);
    result.add(new JLabel("Project name"), cnstrs);

    cnstrs = constraints(1, y++, true, false, GridBagConstraints.NONE);
    result.add(projectName, cnstrs);

    // build options panel
    final JPanel buildOptionsPanel = new JPanel();
    buildOptionsPanel.setLayout(new GridBagLayout());

    buildOptionsPanel.setBorder(BorderFactory.createTitledBorder("Build options"));

    cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE);
    buildOptionsPanel.add(new JLabel("Compilation root"), cnstrs);

    cnstrs = constraints(1, 0, false, false, GridBagConstraints.NONE);
    compilationRootName.setEditable(false);
    compilationRootName.setColumns(25);
    buildOptionsPanel.add(compilationRootName, cnstrs);

    cnstrs = constraints(2, 0, true, false, GridBagConstraints.NONE);
    buildOptionsPanel.add(compilationRootButton, cnstrs);

    compilationRootButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final JFileChooser chooser;
            File baseDir = null;
            if (project != null) {
                baseDir = project.getConfiguration().getBaseDirectory();
            }
            if (StringUtils.isNotBlank(compilationRootName.getText())) {
                File tmp = new File(compilationRootName.getText()).getParentFile();
                if (tmp.exists() && tmp.isDirectory()) {
                    baseDir = tmp;
                }
            }
            if (baseDir != null) {
                chooser = new JFileChooser(baseDir);
            } else {
                chooser = new JFileChooser();
            }
            final int result = chooser.showOpenDialog(null);
            if (result == JFileChooser.APPROVE_OPTION && chooser.getSelectedFile().isFile()) {
                compilationRootName.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });

    // generate self-relocating code ?
    cnstrs = constraints(0, 1, false, false, GridBagConstraints.NONE);
    buildOptionsPanel.add(new JLabel("Generate self-relocating code?"), cnstrs);

    cnstrs = constraints(1, 1, true, true, GridBagConstraints.NONE);
    cnstrs.gridwidth = 2;
    buildOptionsPanel.add(generateSelfRelocatingCode, cnstrs);

    // inline short literals ?
    cnstrs = constraints(0, 2, false, false, GridBagConstraints.NONE);
    buildOptionsPanel.add(new JLabel("Inline short literals?"), cnstrs);

    cnstrs = constraints(1, 2, true, true, GridBagConstraints.NONE);
    cnstrs.gridwidth = 2;
    buildOptionsPanel.add(inlineShortLiterals, cnstrs);

    // add build options panel to parent
    cnstrs = constraints(0, y++, true, false, GridBagConstraints.BOTH);
    cnstrs.gridwidth = 2;
    result.add(buildOptionsPanel, cnstrs);

    // buttons
    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());

    cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE);
    buttonPanel.add(saveButton, cnstrs);
    saveButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (hasValidInput()) {
                onSave();
            }
        }
    });

    cnstrs = constraints(1, 0, true, true, GridBagConstraints.NONE);
    buttonPanel.add(cancelButton, cnstrs);
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            onCancel();
        }
    });

    // button panel
    cnstrs = constraints(0, y++, true, true, GridBagConstraints.NONE);
    cnstrs.gridwidth = 2;
    result.add(buttonPanel, cnstrs);

    return result;
}

From source file:it.cnr.icar.eric.client.ui.swing.FindParamsPanel.java

/**
 * Class Constructor./* ww w . ja  v  a 2s .c  o  m*/
 */
public FindParamsPanel(DiscoveryPanel discoveryPanel) throws JAXRException {
    this.discoveryPanel = discoveryPanel;

    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    //The searchTypeSelectionPanel at the top of the panel
    JPanel searchTypePanel = createSearchTypePanel();
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.NORTH;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(searchTypePanel, c);
    add(searchTypePanel);

    //The federated CheckBox
    federatedCheckBox = new JCheckBox(resourceBundle.getString("label.federatedQuery"));
    federatedCheckBox.setSelected(false);
    federatedCheckBox.setEnabled(true);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.NORTH;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(federatedCheckBox, c);
    add(federatedCheckBox);

    //The actionPanel
    JPanel actionPanel = createActionPanel();
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.NORTH;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(searchTypePanel, c);
    add(actionPanel);

    //Next is the panel that is the parent of both adhocQueryPanel and
    //businessQueryPanel
    paramEntryParentPanel = createParamEntryParentPanel();
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.NORTH;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(paramEntryParentPanel, c);
    add(paramEntryParentPanel);

    //RegistryBrowser.getInstance().getConceptsTreeDialog().addPropertyChangeListener(this);
    //add listener for 'locale' bound property
    RegistryBrowser.getInstance().addPropertyChangeListener(RegistryBrowser.PROPERTY_LOCALE, this);
}