Example usage for java.awt GridBagConstraints BOTH

List of usage examples for java.awt GridBagConstraints BOTH

Introduction

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

Prototype

int BOTH

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

Click Source Link

Document

Resize the component both horizontally and vertically.

Usage

From source file:mazewar.Mazewar.java

/**
 * The place where all the pieces are put together.
 *///from  w w w . ja  v  a 2 s .  com
public Mazewar(String zkServer, int zkPort, int port, String name, String game, boolean robot) {
    super("ECE419 Mazewar");
    consolePrintLn("ECE419 Mazewar started!");

    /* Set up parent */
    ZK_PARENT += game;

    // Throw up a dialog to get the GUIClient name.
    if (name != null) {
        clientId = name;
    } else {
        clientId = JOptionPane.showInputDialog("Enter your name");
    }
    if ((clientId == null) || (clientId.length() == 0)) {
        Mazewar.quit();
    }

    /* Connect to ZooKeeper and get sequencer details */
    List<ClientNode> nodeList = null;
    try {
        zkWatcher = new ZkWatcher();
        zkConnected = new CountDownLatch(1);
        zooKeeper = new ZooKeeper(zkServer + ":" + zkPort, ZK_TIMEOUT, new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                /* Release Lock if ZooKeeper is connected */
                if (event.getState() == SyncConnected) {
                    zkConnected.countDown();
                } else {
                    System.err.println("Could not connect to ZooKeeper!");
                    System.exit(0);
                }
            }
        });
        zkConnected.await();

        /* Successfully connected, now create our node on ZooKeeper */
        zooKeeper.create(Joiner.on('/').join(ZK_PARENT, clientId),
                Joiner.on(':').join(InetAddress.getLocalHost().getHostAddress(), port).getBytes(),
                ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);

        /* Get Seed from Parent */
        mazeSeed = Long.parseLong(new String(zooKeeper.getData(ZK_PARENT, false, null)));

        /* Initialize Sequence Number */
        sequenceNumber = new AtomicInteger(zooKeeper.exists(ZK_PARENT, false).getVersion());

        /* Get list of nodes */
        nodeList = ClientNode.sortList(zooKeeper.getChildren(ZK_PARENT, false));
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }

    // Create the maze
    maze = new MazeImpl(new Point(mazeWidth, mazeHeight), mazeSeed);
    assert (maze != null);

    // Have the ScoreTableModel listen to the maze to find
    // out how to adjust scores.
    ScoreTableModel scoreModel = new ScoreTableModel();
    assert (scoreModel != null);
    maze.addMazeListener(scoreModel);

    /* Initialize packet queue */
    packetQueue = new ArrayBlockingQueue<MazePacket>(QUEUE_SIZE);
    sequencedQueue = new PriorityBlockingQueue<MazePacket>(QUEUE_SIZE, new Comparator<MazePacket>() {
        @Override
        public int compare(MazePacket o1, MazePacket o2) {
            return o1.sequenceNumber.compareTo(o2.sequenceNumber);
        }
    });

    /* Inject Event Bus into Client */
    Client.setEventBus(eventBus);

    /* Initialize ZMQ Context */
    context = ZMQ.context(2);

    /* Set up publisher */
    publisher = context.socket(ZMQ.PUB);
    publisher.bind("tcp://*:" + port);
    System.out.println("ZeroMQ Publisher Bound On: " + port);

    try {
        Thread.sleep(100);
    } catch (Exception e) {
        e.printStackTrace();
    }

    /* Set up subscriber */
    subscriber = context.socket(ZMQ.SUB);
    subscriber.subscribe(ArrayUtils.EMPTY_BYTE_ARRAY);

    clients = new ConcurrentHashMap<String, Client>();
    try {
        for (ClientNode client : nodeList) {
            if (client.getName().equals(clientId)) {
                clientPath = ZK_PARENT + "/" + client.getPath();
                guiClient = robot ? new RobotClient(clientId) : new GUIClient(clientId);
                clients.put(clientId, guiClient);
                maze.addClient(guiClient);
                eventBus.register(guiClient);
                subscriber.connect("tcp://" + new String(zooKeeper.getData(clientPath, false, null)));
            } else {
                addRemoteClient(client);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    checkNotNull(guiClient, "Should have received our clientId in CLIENTS list!");

    // Create the GUIClient and connect it to the KeyListener queue
    this.addKeyListener(guiClient);
    this.isRobot = robot;

    // Use braces to force constructors not to be called at the beginning of the
    // constructor.
    /*{
    maze.addClient(new RobotClient("Norby"));
    maze.addClient(new RobotClient("Robbie"));
    maze.addClient(new RobotClient("Clango"));
    maze.addClient(new RobotClient("Marvin"));
    }*/

    // Create the panel that will display the maze.
    overheadPanel = new OverheadMazePanel(maze, guiClient);
    assert (overheadPanel != null);
    maze.addMazeListener(overheadPanel);

    // Don't allow editing the console from the GUI
    console.setEditable(false);
    console.setFocusable(false);
    console.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder()));

    // Allow the console to scroll by putting it in a scrollpane
    JScrollPane consoleScrollPane = new JScrollPane(console);
    assert (consoleScrollPane != null);
    consoleScrollPane
            .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Console"));

    // Create the score table
    scoreTable = new JTable(scoreModel);
    assert (scoreTable != null);
    scoreTable.setFocusable(false);
    scoreTable.setRowSelectionAllowed(false);

    // Allow the score table to scroll too.
    JScrollPane scoreScrollPane = new JScrollPane(scoreTable);
    assert (scoreScrollPane != null);
    scoreScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Scores"));

    // Create the layout manager
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    getContentPane().setLayout(layout);

    // Define the constraints on the components.
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 3.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    layout.setConstraints(overheadPanel, c);
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.weightx = 2.0;
    c.weighty = 1.0;
    layout.setConstraints(consoleScrollPane, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    layout.setConstraints(scoreScrollPane, c);

    // Add the components
    getContentPane().add(overheadPanel);
    getContentPane().add(consoleScrollPane);
    getContentPane().add(scoreScrollPane);

    // Pack everything neatly.
    pack();

    // Let the magic begin.
    setVisible(true);
    overheadPanel.repaint();
    this.requestFocusInWindow();
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.navegacao_cego.PainelSimuladorNavegacao.java

/**
 * Cria os componentes/*from www.  j a  v  a  2s  . com*/
 * 
 */
private void initComponentsEscalavel() {
    TradSimuladorNavegacao.carregaTexto(TokenLang.LANG);
    JPanel regraFonteBtn = new JPanel();
    regraFonteBtn.setLayout(new BorderLayout());

    textAreaSourceCode = new G_TextAreaSourceCode();
    textAreaSourceCode.getTextPane().setEditable(false);

    // scrollPaneDescricao.getTextPane().setContentType("text/html;");
    conteudoDoAlt = new JTextArea();
    parentFrame.setTitle(TradSimuladorNavegacao.TITULO_SIMULADOR_CEGO);
    parentFrame.setJMenuBar(this.criaMenuBar());
    tabelaDescricao = new TabelaDescricao(this);
    tabelaDescricao.addMouseListener(this);
    conteudoDoAlt = new JTextArea();
    abrir = new JButton();
    cancelar = new JButton();
    btnSalvar = new JMenuItem(GERAL.BTN_SALVAR);

    pnRegra = new JPanel();
    lbRegras1 = new JLabel();
    lbRegras2 = new JLabel();
    pnSetaDescricao = new JPanel();
    spTextoDescricao = new JScrollPane();

    pnListaErros = new JPanel();
    scrollPanetabLinCod = new JScrollPane();

    pnBotoes = new JPanel();

    buscar = new JButton();

    this.setBackground(CoresDefault.getCorPaineis());
    Container contentPane = this;// ??
    contentPane.setLayout(new GridLayout(2, 1));

    // ======== pnRegra ========
    {
        pnRegra.setBorder(criaBorda(""));
        pnRegra.setLayout(new GridLayout(2, 1));
        pnRegra.add(lbRegras1);
        lbRegras1.setText(TradSimuladorNavegacao.SELECIONE_ITEM_TABELA);
        lbRegras2.setText(TradSimuladorNavegacao.DE_UMA_PAGINA);
        lbRegras1.setHorizontalAlignment(SwingConstants.CENTER);

        lbRegras2.setHorizontalAlignment(SwingConstants.CENTER);
        pnRegra.add(lbRegras1);
        pnRegra.add(lbRegras2);
        pnRegra.setPreferredSize(new Dimension(700, 60));
    }

    // G_URLIcon.setIcon(lbTemp,
    // "http://pitecos.blogs.sapo.pt/arquivo/pai%20natal%20o5.%20jpg.jpg");

    // ======== pnDescricao ========

    abrir.setText(Ferramenta_Scripts.BTN_ABRIR);
    abrir.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AbrirActionPerformed(e);
        }
    });

    abrir.setToolTipText(Ferramenta_Scripts.DICA_ABRIR);
    abrir.getAccessibleContext().setAccessibleDescription(Ferramenta_Scripts.DICA_ABRIR_HTML);
    abrir.getAccessibleContext().setAccessibleName(Ferramenta_Scripts.DICA_ABRIR_HTML);
    abrir.setBounds(10, 0, 150, 25);

    cancelar.setText(Ferramenta_Imagens.TELA_ANTERIOR);
    cancelar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            CancelarActionPerformed(e);
        }
    });

    cancelar.setToolTipText(Ferramenta_Imagens.DICA_TELA_ANTERIOR);
    cancelar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_TELA_ANTERIOR);
    cancelar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.TELA_ANTERIOR);
    cancelar.setBounds(165, 0, 150, 25);

    // ======== pnParticRotulo ========

    pnSetaDescricao.setBorder(criaBorda(TradSimuladorNavegacao.DIGITE_TEXTO_BUSCADO));
    GridBagConstraints cons = new GridBagConstraints();
    GridBagLayout layout = new GridBagLayout();
    cons.fill = GridBagConstraints.BOTH;
    cons.weighty = 1;
    cons.weightx = 0.80;

    pnSetaDescricao.setLayout(layout);
    cons.anchor = GridBagConstraints.SOUTHEAST;
    cons.insets = new Insets(0, 0, 0, 10);
    // ======== spParticRotulo ========
    {
        spTextoDescricao.setViewportView(conteudoDoAlt);
    }

    pnSetaDescricao.add(spTextoDescricao, cons);
    cons.weightx = 0.20;
    pnSetaDescricao.setPreferredSize(new Dimension(400, 60));

    // ======== pnListaErros ========
    {

        pnListaErros.setBorder(criaBorda(TradSimuladorNavegacao.LINKS_INTERNOS));
        pnListaErros.setLayout(new BorderLayout());
        // ======== scrollPanetabLinCod ========
        {
            scrollPanetabLinCod.setViewportView(tabelaDescricao);
        }
        pnListaErros.add(scrollPanetabLinCod, BorderLayout.CENTER);
    }
    // ======== pnBotoes ========
    {

        // pnBotoes.setBorder(criaBorda(""));

        pnBotoes.setLayout(null);
        // ---- adicionar ----

        // ---- aplicarRotulo ----

        buscar.setText(TradSimuladorNavegacao.BUSCAR_PROXIMA);
        buscar.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                BuscarActionPerformed(e);
            }
        });

        buscar.setToolTipText(TradSimuladorNavegacao.BUSCAR_TEXTO);
        buscar.getAccessibleContext().setAccessibleDescription(TradSimuladorNavegacao.BUSCAR_TEXTO);
        buscar.getAccessibleContext().setAccessibleName(TradSimuladorNavegacao.BUSCAR_TEXTO);
        buscar.setBounds(10, 5, 150, 25);
        pnBotoes.add(buscar);
    }

    /*
     * Colocar os controles
     */
    pnRegra.setBackground(CoresDefault.getCorPaineis());
    regraFonteBtn.add(pnRegra, BorderLayout.NORTH);
    textAreaSourceCode.setBorder(criaBorda(""));
    textAreaSourceCode.setBackground(CoresDefault.getCorPaineis());

    // JScrollPane ajudaScrollPane = new
    // JScrollPane(ajuda,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    // regraFonteBtn.add(scrollPaneCorrecaoLabel, BorderLayout.CENTER);
    regraFonteBtn.add(textAreaSourceCode, BorderLayout.CENTER);
    pnBotoes.setPreferredSize(new Dimension(600, 35));
    pnBotoes.setBackground(CoresDefault.getCorPaineis());
    // regraFonteBtn.add(pnBotoes, BorderLayout.SOUTH);
    regraFonteBtn.setBackground(CoresDefault.getCorPaineis());
    contentPane.add(regraFonteBtn);

    JPanel textoErrosBtn = new JPanel();
    textoErrosBtn.setLayout(new BorderLayout());
    pnSetaDescricao.setBackground(CoresDefault.getCorPaineis());
    pnSetaDescricao.add(pnBotoes, cons);
    textoErrosBtn.add(pnSetaDescricao, BorderLayout.NORTH);

    textoErrosBtn.add(pnListaErros, BorderLayout.CENTER);
    JPanel pnSalvarCancelar = new JPanel();
    pnSalvarCancelar.setLayout(null);
    pnSalvarCancelar.setPreferredSize(new Dimension(600, 35));

    pnSalvarCancelar.add(abrir);
    pnSalvarCancelar.add(cancelar);
    pnSalvarCancelar.setBackground(CoresDefault.getCorPaineis());
    textoErrosBtn.add(pnSalvarCancelar, BorderLayout.SOUTH);
    pnListaErros.setBackground(CoresDefault.getCorPaineis());

    contentPane.setBackground(CoresDefault.getCorPaineis());
    contentPane.add(textoErrosBtn);

    this.setVisible(true);

}

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

@SuppressWarnings({ "rawtypes", "unchecked" })
private JPanel createQuerySelectionPanel() {
    JPanel querySelectionPanel = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    querySelectionPanel.setLayout(gbl);//w  w w  .  jav a  2s  .  c o  m

    //The selectQueryCombo
    selectQueryLabel = new JLabel(resourceBundle.getString("title.selectQuery"), SwingConstants.LEADING);
    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.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(selectQueryLabel, c);
    querySelectionPanel.add(selectQueryLabel);

    //TODO: SwingBoost: localize this:
    selectQueryCombo = new JComboBox(new String[] { "loading queries..." });
    selectQueryCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            RegistryBrowser.setWaitCursor();
            if (ev.getStateChange() == ItemEvent.DESELECTED) {
                return;
            }

            @SuppressWarnings("unused")
            String item = (String) ev.getItem();
            int index = ((JComboBox) ev.getSource()).getSelectedIndex();

            QueryType uiQueryType = queries.get(index);

            try {
                setQuery(uiQueryType);
            } catch (JAXRException e) {
                RegistryBrowser.setDefaultCursor();
                throw new UndeclaredThrowableException(e);
            }
            RegistryBrowser.setDefaultCursor();
        }
    });

    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(selectQueryCombo, c);
    querySelectionPanel.add(selectQueryCombo);

    //The nameTextField
    queryNameLabel = new JLabel(resourceBundle.getString("title.name"), SwingConstants.LEADING);
    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.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(queryNameLabel, c);
    querySelectionPanel.add(queryNameLabel);

    queryNameText = new JTextField();
    queryNameText.setEditable(false);
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(queryNameText, c);
    querySelectionPanel.add(queryNameText);

    //The description TextArea
    queryDescLabel = new JLabel(resourceBundle.getString("title.description"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(queryDescLabel, c);
    querySelectionPanel.add(queryDescLabel);

    queryDescText = new JTextArea(4, 25);
    queryDescText.setLineWrap(true);
    queryDescText.setEditable(false);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(queryDescText, c);
    querySelectionPanel.add(queryDescText);

    return querySelectionPanel;
}

From source file:org.languagetool.gui.ConfigurationDialog.java

public boolean show(List<Rule> rules) {
    configChanged = false;/*  ww w . j  a va 2  s. c o  m*/
    if (original != null) {
        config.restoreState(original);
    }
    dialog = new JDialog(owner, true);
    dialog.setTitle(messages.getString("guiConfigWindowTitle"));
    // close dialog when user presses Escape key:
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    ActionListener actionListener = new ActionListener() {
        @Override
        public void actionPerformed(@SuppressWarnings("unused") ActionEvent actionEvent) {
            dialog.setVisible(false);
        }
    };
    JRootPane rootPane = dialog.getRootPane();
    rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    configurableRules.clear();

    Language lang = config.getLanguage();
    if (lang == null) {
        lang = Languages.getLanguageForLocale(Locale.getDefault());
    }

    String specialTabNames[] = config.getSpecialTabNames();
    int numConfigTrees = 2 + specialTabNames.length;
    configTree = new JTree[numConfigTrees];
    JPanel checkBoxPanel[] = new JPanel[numConfigTrees];
    DefaultMutableTreeNode rootNode;
    GridBagConstraints cons;

    for (int i = 0; i < numConfigTrees; i++) {
        checkBoxPanel[i] = new JPanel();
        cons = new GridBagConstraints();
        checkBoxPanel[i].setLayout(new GridBagLayout());
        cons.anchor = GridBagConstraints.NORTHWEST;
        cons.gridx = 0;
        cons.weightx = 1.0;
        cons.weighty = 1.0;
        cons.fill = GridBagConstraints.HORIZONTAL;
        Collections.sort(rules, new CategoryComparator());
        if (i == 0) {
            rootNode = createTree(rules, false, null); //  grammar options
        } else if (i == 1) {
            rootNode = createTree(rules, true, null); //  Style options
        } else {
            rootNode = createTree(rules, true, specialTabNames[i - 2]); //  Special tab options
        }
        configTree[i] = new JTree(getTreeModel(rootNode));

        configTree[i].applyComponentOrientation(ComponentOrientation.getOrientation(lang.getLocale()));

        configTree[i].setRootVisible(false);
        configTree[i].setEditable(false);
        configTree[i].setCellRenderer(new CheckBoxTreeCellRenderer());
        TreeListener.install(configTree[i]);
        checkBoxPanel[i].add(configTree[i], cons);
        configTree[i].addMouseListener(getMouseAdapter());
    }

    JPanel portPanel = new JPanel();
    portPanel.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.anchor = GridBagConstraints.WEST;
    cons.fill = GridBagConstraints.NONE;
    cons.weightx = 0.0f;
    if (!insideOffice) {
        createNonOfficeElements(cons, portPanel);
    } else {
        createOfficeElements(cons, portPanel);
    }

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridBagLayout());
    JButton okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton")));
    okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton")));
    okButton.setActionCommand(ACTION_COMMAND_OK);
    okButton.addActionListener(this);
    JButton cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton")));
    cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton")));
    cancelButton.setActionCommand(ACTION_COMMAND_CANCEL);
    cancelButton.addActionListener(this);
    cons = new GridBagConstraints();
    cons.insets = new Insets(0, 4, 0, 0);
    buttonPanel.add(okButton, cons);
    buttonPanel.add(cancelButton, cons);

    JTabbedPane tabpane = new JTabbedPane();

    JPanel jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);

    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 0.0f;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.NORTHWEST;
    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getMotherTonguePanel(cons), cons);

    if (insideOffice) {
        cons.gridy += 3;
    } else {
        cons.gridy++;
    }
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getNgramPanel(cons), cons);

    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(getWord2VecPanel(cons), cons);

    cons.gridy++;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(portPanel, cons);
    cons.fill = GridBagConstraints.HORIZONTAL;
    cons.anchor = GridBagConstraints.WEST;
    for (JPanel extra : extraPanels) {
        //in case it wasn't in a containment hierarchy when user changed L&F
        SwingUtilities.updateComponentTreeUI(extra);
        cons.gridy++;
        jPane.add(extra, cons);
    }

    cons.gridy++;
    cons.fill = GridBagConstraints.BOTH;
    cons.weighty = 1.0f;
    jPane.add(new JPanel(), cons);

    tabpane.addTab(messages.getString("guiGeneral"), jPane);

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    jPane.add(new JScrollPane(checkBoxPanel[0]), cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;

    cons.gridx = 0;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    jPane.add(getTreeButtonPanel(0), cons);

    tabpane.addTab(messages.getString("guiGrammarRules"), jPane);

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    jPane.add(new JScrollPane(checkBoxPanel[1]), cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;

    cons.gridx = 0;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.LINE_END;
    jPane.add(getTreeButtonPanel(1), cons);

    cons.gridx = 0;
    cons.gridy++;
    cons.weightx = 5.0f;
    cons.weighty = 5.0f;
    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.WEST;
    jPane.add(new JScrollPane(getSpecialRuleValuePanel()), cons);

    tabpane.addTab(messages.getString("guiStyleRules"), jPane);

    for (int i = 0; i < specialTabNames.length; i++) {
        jPane = new JPanel();
        jPane.setLayout(new GridBagLayout());
        cons = new GridBagConstraints();
        cons.insets = new Insets(4, 4, 4, 4);
        cons.gridx = 0;
        cons.gridy = 0;
        cons.weightx = 10.0f;
        cons.weighty = 10.0f;
        cons.fill = GridBagConstraints.BOTH;
        jPane.add(new JScrollPane(checkBoxPanel[i + 2]), cons);
        cons.weightx = 0.0f;
        cons.weighty = 0.0f;

        cons.gridx = 0;
        cons.gridy++;
        cons.fill = GridBagConstraints.NONE;
        cons.anchor = GridBagConstraints.LINE_END;
        jPane.add(getTreeButtonPanel(i + 2), cons);

        tabpane.addTab(specialTabNames[i], jPane);
    }

    jPane = new JPanel();
    jPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    if (insideOffice) {
        JLabel versionText = new JLabel(messages.getString("guiUColorHint"));
        versionText.setForeground(Color.blue);
        jPane.add(versionText, cons);
        cons.gridy++;
    }

    cons.weightx = 2.0f;
    cons.weighty = 2.0f;
    cons.fill = GridBagConstraints.BOTH;

    jPane.add(new JScrollPane(getUnderlineColorPanel(rules)), cons);

    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new GridBagLayout());
    cons = new GridBagConstraints();
    cons.insets = new Insets(4, 4, 4, 4);
    cons.gridx = 0;
    cons.gridy = 0;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.fill = GridBagConstraints.BOTH;
    cons.anchor = GridBagConstraints.NORTHWEST;
    contentPane.add(tabpane, cons);
    cons.weightx = 0.0f;
    cons.weighty = 0.0f;
    cons.gridy++;
    cons.fill = GridBagConstraints.NONE;
    cons.anchor = GridBagConstraints.EAST;
    contentPane.add(buttonPanel, cons);

    dialog.pack();
    // center on screen:
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = dialog.getSize();
    dialog.setLocation(screenSize.width / 2 - frameSize.width / 2,
            screenSize.height / 2 - frameSize.height / 2);
    dialog.setLocationByPlatform(true);
    //  add Color tab after dimension was set
    tabpane.addTab(messages.getString("guiUnderlineColor"), jPane);

    for (JPanel extra : this.extraPanels) {
        if (extra instanceof SavablePanel) {
            ((SavablePanel) extra).componentShowing();
        }
    }
    dialog.setVisible(true);
    return configChanged;
}

From source file:me.childintime.childintime.ui.window.tool.BmiToolDialog.java

/**
 * Build the UI student panel.//from  w  ww .j  a va2 s .com
 *
 * @return Student panel.
 */
private JPanel buildUiStudentPanel() {
    // Create a grid bag constraints configuration
    GridBagConstraints c = new GridBagConstraints();

    // Create a panel for the student selector
    final JPanel studentPanel = new JPanel(new GridBagLayout());

    // Create a group filter property field
    this.groupFilterField = new EntityPropertyField(Core.getInstance().getGroupManager(), true);
    this.groupFilterField.setNull(true);

    // Add the student label
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(0, 2, 2, 0);
    c.anchor = GridBagConstraints.SOUTHWEST;
    studentPanel.add(new JLabel("Student group filter:"), c);

    // Add the group filter
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.insets = new Insets(0, 0, 8, 0);
    c.anchor = GridBagConstraints.CENTER;
    studentPanel.add(this.groupFilterField, c);

    // Create a student selector list
    this.studentList = new EntityListSelectorComponent(Core.getInstance().getStudentManager());

    // Create a listener to set the student list filter when the group changes
    this.groupFilterField.addValueChangeListenerListener(newValue -> {
        // Set or clear the filter
        if (newValue != null)
            this.studentList.setFilter(StudentFields.GROUP_ID, newValue);
        else
            this.studentList.clearFilter();
    });

    // Add the student label
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 0;
    c.weighty = 0;
    c.insets = new Insets(8, 2, 2, 0);
    c.anchor = GridBagConstraints.SOUTHWEST;
    studentPanel.add(new JLabel("Student:"), c);

    // Add the student list
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 3;
    c.weightx = 1;
    c.weighty = 1;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    studentPanel.add(this.studentList, c);

    // Set the minimum preferred size
    studentPanel.setPreferredSize(new Dimension(200, 200));

    // Return the student panel
    return studentPanel;
}

From source file:org.openconcerto.erp.core.sales.shipment.component.BonDeLivraisonSQLComponent.java

public void addViews() {
    this.textTotalHT.setOpaque(false);
    this.textTotalTVA.setOpaque(false);
    this.textTotalTTC.setOpaque(false);

    this.selectCommande = new ElementComboBox();

    this.setLayout(new GridBagLayout());

    final GridBagConstraints c = new DefaultGridBagConstraints();

    // Champ Module
    c.gridx = 0;/* w  ww.j  a v a 2s  .co  m*/
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    // Numero
    JLabel labelNum = new JLabel(getLabelFor("NUMERO"));
    labelNum.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelNum, c);

    this.textNumeroUnique = new JUniqueTextField(16);
    c.gridx++;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    DefaultGridBagConstraints.lockMinimumSize(textNumeroUnique);
    this.add(this.textNumeroUnique, c);

    // Date
    c.gridx++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    this.add(new JLabel(getLabelFor("DATE"), SwingConstants.RIGHT), c);

    JDate date = new JDate(true);
    c.gridx++;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(date, c);

    // Reference
    c.gridy++;
    c.gridx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c);
    c.gridx++;
    c.weightx = 1;
    this.add(this.textNom, c);
    if (getTable().contains("DATE_LIVRAISON")) {
        // Date livraison
        c.gridx++;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 0;
        this.add(new JLabel(getLabelFor("DATE_LIVRAISON"), SwingConstants.RIGHT), c);

        JDate dateLivraison = new JDate(true);
        c.gridx++;
        c.weightx = 0;
        c.weighty = 0;
        c.fill = GridBagConstraints.NONE;
        this.add(dateLivraison, c);
        this.addView(dateLivraison, "DATE_LIVRAISON");
    }
    // Client
    JLabel labelClient = new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT);
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weighty = 0;
    this.add(labelClient, c);

    c.gridx++;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.comboClient = new ElementComboBox();
    this.add(this.comboClient, c);
    if (getTable().contains("SPEC_LIVRAISON")) {
        // Date livraison
        c.gridx++;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 0;
        this.add(new JLabel(getLabelFor("SPEC_LIVRAISON"), SwingConstants.RIGHT), c);

        JTextField specLivraison = new JTextField();
        c.gridx++;
        c.weightx = 0;
        c.weighty = 0;
        this.add(specLivraison, c);
        this.addView(specLivraison, "SPEC_LIVRAISON");
    }

    final ElementComboBox boxTarif = new ElementComboBox();
    this.comboClient.addValueListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (comboClient.getElement().getTable().contains("ID_TARIF")) {
                if (BonDeLivraisonSQLComponent.this.isFilling())
                    return;
                final SQLRow row = ((SQLRequestComboBox) evt.getSource()).getSelectedRow();
                if (row != null) {
                    // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                    // if (foreignRow.isUndefined() &&
                    // !row.getForeignRow("ID_DEVISE").isUndefined()) {
                    // SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable());
                    // rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE"));
                    // foreignRow = rowValsD;
                    //
                    // }
                    // tableBonItem.setTarif(foreignRow, true);
                    SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                    if (!foreignRow.isUndefined()
                            && (boxTarif.getSelectedRow() == null
                                    || boxTarif.getSelectedId() != foreignRow.getID())
                            && JOptionPane.showConfirmDialog(null,
                                    "Appliquer les tarifs associs au client?") == JOptionPane.YES_OPTION) {
                        boxTarif.setValue(foreignRow.getID());
                        // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
                        // true);
                    } else {
                        boxTarif.setValue(foreignRow.getID());
                    }
                }
            }
        }
    });

    // Bouton tout livrer
    JButton boutonAll = new JButton("Tout livrer");

    boutonAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            RowValuesTableModel m = BonDeLivraisonSQLComponent.this.tableBonItem.getModel();

            // on livre tout les lments
            for (int i = 0; i < m.getRowCount(); i++) {
                SQLRowValues rowVals = m.getRowValuesAt(i);
                Object o = rowVals.getObject("QTE");
                int qte = o == null ? 0 : ((Number) o).intValue();
                m.putValue(qte, i, "QTE_LIVREE");
            }
        }
    });

    // Tarif
    if (this.getTable().getFieldsName().contains("ID_TARIF")) {
        // TARIF
        c.gridy++;
        c.gridx = 0;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        this.add(new JLabel("Tarif  appliquer"), c);
        c.gridx++;
        c.gridwidth = 1;

        c.weightx = 1;
        this.add(boxTarif, c);
        this.addView(boxTarif, "ID_TARIF");
        boxTarif.addModelListener("wantedID", new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
                tableBonItem.setTarif(selectedRow, !isFilling());
            }
        });
    }

    if (getTable().contains("A_ATTENTION")) {
        // Date livraison
        c.gridx++;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 0;
        this.add(new JLabel(getLabelFor("A_ATTENTION"), SwingConstants.RIGHT), c);

        JTextField specLivraison = new JTextField();
        c.gridx++;
        c.weightx = 0;
        c.weighty = 0;
        this.add(specLivraison, c);
        this.addView(specLivraison, "A_ATTENTION");
    }

    // Element du bon
    List<JButton> l = new ArrayList<JButton>();
    l.add(boutonAll);
    this.tableBonItem = new BonDeLivraisonItemTable(l);

    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    this.add(this.tableBonItem, c);
    c.anchor = GridBagConstraints.EAST;
    // Totaux
    reconfigure(this.textTotalHT);
    reconfigure(this.textTotalTVA);
    reconfigure(this.textTotalTTC);

    // Poids Total
    c.gridy++;
    c.gridx = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    this.addSQLObject(this.textPoidsTotal, "TOTAL_POIDS");
    this.addRequiredSQLObject(this.textTotalHT, "TOTAL_HT");
    this.addRequiredSQLObject(this.textTotalTVA, "TOTAL_TVA");
    this.addRequiredSQLObject(this.textTotalTTC, "TOTAL_TTC");
    TotalPanel panelTotal = new TotalPanel(tableBonItem, textTotalHT, textTotalTVA, textTotalTTC,
            new DeviseField(), new DeviseField(), new DeviseField(), new DeviseField(), new DeviseField(),
            textPoidsTotal, null);
    c.gridx = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(panelTotal, c);

    c.anchor = GridBagConstraints.WEST;

    /*******************************************************************************************
     * * INFORMATIONS COMPLEMENTAIRES
     ******************************************************************************************/
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy++;
    TitledSeparator sep = new TitledSeparator("Informations complmentaires");
    c.insets = new Insets(10, 2, 1, 2);
    this.add(sep, c);
    c.insets = new Insets(2, 2, 1, 2);

    ITextArea textInfos = new ITextArea(4, 4);

    c.gridx = 0;
    c.gridy++;
    c.gridheight = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.BOTH;

    final JScrollPane scrollPane = new JScrollPane(textInfos);
    this.add(scrollPane, c);
    textInfos.setBorder(null);
    DefaultGridBagConstraints.lockMinimumSize(scrollPane);

    c.gridx = 0;
    c.gridy++;
    c.gridheight = 1;
    c.gridwidth = 4;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;

    this.panelOO = new PanelOOSQLComponent(this);
    this.add(this.panelOO, c);

    this.addRequiredSQLObject(date, "DATE");
    this.addSQLObject(textInfos, "INFOS");
    this.addSQLObject(this.textNom, "NOM");
    this.addSQLObject(this.selectCommande, "ID_COMMANDE_CLIENT");
    this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO");

    this.addRequiredSQLObject(this.comboClient, "ID_CLIENT");

    // Doit etre lock a la fin
    DefaultGridBagConstraints.lockMinimumSize(comboClient);

}

From source file:de.juwimm.cms.content.panel.PanDocuments.java

private void jbInit() throws Exception {
    mimeType = "";
    btnDelete.setText("Datei lschen");
    panBottom.setLayout(new BorderLayout());
    panDocumentButtons.setLayout(panDocumentsLayout);
    btnAdd.setText("Datei hinzufgen");
    lbLinkDescription.setText(" Linkbeschreibung  ");
    this.setLayout(new BorderLayout());
    panLinkName.setLayout(panLinkNameLayout);
    panDocumentsLayout.setAlignment(FlowLayout.LEFT);
    panDocumentButtons.setBackground(SystemColor.text);
    this.add(panBottom, BorderLayout.SOUTH);
    panBottom.add(panFileAction, BorderLayout.EAST);
    panFileAction.add(btnUpdate, null);/*w w  w.  jav  a  2s.  co m*/
    panFileAction.add(btnAdd, null);
    panFileAction.add(btnDelete, null);
    panFileAction.add(btnPreview, null);
    panBottom.add(panLinkName, BorderLayout.NORTH);
    panLinkName.add(lbLinkDescription, new GridBagConstraints(0, 0, 1, 1, 0, 0,
            GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2));
    panLinkName.add(txtLinkDesc, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.BASELINE_LEADING,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2));
    if (showDocumentProperties) {
        panLinkName.add(lbDocumentLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0,
                GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2));
        panLinkName.add(txtDocumentLabel, new GridBagConstraints(1, 1, 1, 1, 1, 0,
                GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2));
        panLinkName.add(lbDocumentDescription, new GridBagConstraints(0, 2, 1, 1, 0, 0,
                GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2));
        panLinkName.add(txtDocumentDescription, new GridBagConstraints(1, 2, 1, 1, 1, 0,
                GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2));
        panLinkName.add(lbAuthor, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.BASELINE_LEADING,
                GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2));
        panLinkName.add(txtAuthor, new GridBagConstraints(1, 3, 1, 1, 1, 0, GridBagConstraints.BASELINE_LEADING,
                GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2));
        panLinkName.add(lbCategory, new GridBagConstraints(0, 4, 1, 1, 0, 0,
                GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2));
        panLinkName.add(txtCategory, new GridBagConstraints(1, 4, 1, 1, 1, 0,
                GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2));
        panLinkName.add(ckbDocumentSearchable, new GridBagConstraints(0, 5, 2, 1, 1, 1,
                GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 2, 2));
    }
    panBottom.add(cbxDisplayTypeInline, BorderLayout.WEST);
    this.add(scrollPane, BorderLayout.CENTER);
    if (showRegionCombo) {
        this.add(cboRegion, BorderLayout.NORTH);
    }

    this.add(getViewSelectPan(), BorderLayout.WEST);
    scrollPane.getViewport().add(tblDocuments, null);
    scrollPane.setTransferHandler(new FileTransferHandler(this));
}

From source file:com.rapidminer.gui.new_plotter.gui.ColorSchemeDialog.java

/**
 *
 *///from w  w w.ja v  a  2 s  . com
private void createComponents() {

    // creat popup menus
    {

        popupMenu = new JPopupMenu();
        removeMenuItem = new JMenuItem(I18N
                .getGUILabel("plotter.configuration_dialog.color_scheme_dialog.remove_color_menu_item.label"));
        removeMenuItem.addActionListener(new ActionListener() {

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

        });
        popupMenu.add(removeMenuItem);

        changeColorMenuItem = new JMenuItem(I18N
                .getGUILabel("plotter.configuration_dialog.color_scheme_dialog.change_color_menu_item.label"));
        changeColorMenuItem.addActionListener(new ActionListener() {

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

        });
        popupMenu.add(changeColorMenuItem);

        popupMenu.addSeparator();

        moveUpColorMenuItem = new JMenuItem(
                I18N.getGUILabel("plotter.configuration_dialog.color_scheme_dialog.move_up_menu_item.label"));
        moveUpColorMenuItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                moveSelectedColorUpAction();

            }

        });
        popupMenu.add(moveUpColorMenuItem);

        moveDownColorMenuItem = new JMenuItem(
                I18N.getGUILabel("plotter.configuration_dialog.color_scheme_dialog.move_down_menu_item.label"));
        moveDownColorMenuItem.addActionListener(new ActionListener() {

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

        });
        popupMenu.add(moveDownColorMenuItem);

    }

    JPanel containerPanel = new JPanel(new GridBagLayout());
    containerPanel.setPreferredSize(new Dimension(520, 450));

    // create containing panel
    {

        {
            JPanel configurePanel = new JPanel(new GridBagLayout());
            configurePanel.setPreferredSize(new Dimension(220, 400));
            configurePanel.setBorder(BorderFactory.createTitledBorder(I18N.getGUILabel(
                    "plotter.configuration_dialog.color_scheme_dialog.scheme_configuration_border.label")));

            // add scheme list panel
            {
                JPanel schemeComboBoxPanel = createSchemeComboBoxPanel();

                // add category choosing panel
                GridBagConstraints itemConstraint = new GridBagConstraints();
                itemConstraint.fill = GridBagConstraints.BOTH;
                itemConstraint.weightx = 1;
                itemConstraint.weighty = 1;
                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.insets = new Insets(2, 2, 2, 5);

                configurePanel.add(schemeComboBoxPanel, itemConstraint);
            }

            {
                categoryAndGradientConfigPanel = new JPanel(new GridBagLayout());

                // add categories panel
                {
                    JPanel categoryConfigurationPanel = createColorCategoriesPanel();

                    // add category choosing panel
                    GridBagConstraints itemConstraint = new GridBagConstraints();
                    itemConstraint.fill = GridBagConstraints.BOTH;
                    itemConstraint.weightx = 1;
                    itemConstraint.weighty = 1;
                    itemConstraint.insets = new Insets(2, 2, 2, 5);
                    itemConstraint.gridwidth = GridBagConstraints.REMAINDER;

                    categoryAndGradientConfigPanel.add(categoryConfigurationPanel, itemConstraint);

                }

                // add gradient chooser panel
                {
                    JPanel gradientConfigPanel = createGradientConfigurationPanel();

                    GridBagConstraints itemConstraint = new GridBagConstraints();
                    itemConstraint.fill = GridBagConstraints.BOTH;
                    itemConstraint.weightx = 1;
                    itemConstraint.weighty = 1;
                    itemConstraint.insets = new Insets(2, 2, 2, 5);
                    itemConstraint.gridwidth = GridBagConstraints.REMAINDER;

                    categoryAndGradientConfigPanel.add(gradientConfigPanel, itemConstraint);
                }

                GridBagConstraints itemConstraint = new GridBagConstraints();
                itemConstraint.fill = GridBagConstraints.BOTH;
                itemConstraint.weightx = 1;
                itemConstraint.weighty = 1;
                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.insets = new Insets(2, 2, 2, 5);

                configurePanel.add(categoryAndGradientConfigPanel, itemConstraint);

            }

            GridBagConstraints itemConstraint = new GridBagConstraints();
            itemConstraint.fill = GridBagConstraints.BOTH;
            itemConstraint.weightx = 1;
            itemConstraint.weighty = 1;
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
            containerPanel.add(configurePanel, itemConstraint);
        }

        createPlotPreviewPanel(containerPanel);

    }

    // create buttons
    Collection<AbstractButton> buttons = new LinkedList<AbstractButton>();
    buttons.add(makeOkButton());

    Action saveAction = new ResourceAction("plotter.configuration_dialog.color_scheme_dialog.save_button") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            save(currentColorSchemes, currentActiveColorSchemeName);

            // set new scheme
            plotConfig.setColorSchemes(currentColorSchemes, currentActiveColorSchemeName);
        }
    };
    saveButton = new JButton(saveAction);
    buttons.add(saveButton);
    saveButton.setEnabled(false);

    Action revertAction = new ResourceAction("plotter.configuration_dialog.color_scheme_dialog.revert_button") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            revert();
        }
    };
    revertButton = new JButton(revertAction);
    revertButton.setEnabled(false);
    buttons.add(revertButton);
    buttons.add(makeCancelButton("plotter.configuration_dialog.color_scheme_dialog.cancel_button"));

    layoutDefault(containerPanel, buttons);
}

From source file:net.sf.jabref.gui.plaintextimport.TextInputDialog.java

private JPanel setUpFieldListPanel() {
    JPanel inputPanel = new JPanel();

    // Panel Layout
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints con = new GridBagConstraints();
    con.weightx = 0;//from   w  w w  . ja va 2s . c  o  m
    con.insets = new Insets(5, 5, 0, 5);
    con.fill = GridBagConstraints.HORIZONTAL;

    inputPanel.setLayout(gbl);

    // Border
    TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createLineBorder(new Color(153, 153, 153), 2),
            Localization.lang("Work options"));
    inputPanel.setBorder(titledBorder1);
    inputPanel.setMinimumSize(new Dimension(10, 10));

    JScrollPane fieldScroller = new JScrollPane(fieldList);
    fieldScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    // insert buttons
    insertButton.addActionListener(event -> insertTextForTag(override.isSelected()));

    // Radio buttons
    append.setToolTipText(Localization.lang("Append the selected text to BibTeX field"));
    append.setMnemonic(KeyEvent.VK_A);
    append.setSelected(true);

    override.setToolTipText(Localization.lang("Override the BibTeX field by the selected text"));
    override.setMnemonic(KeyEvent.VK_O);
    override.setSelected(false);

    //Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(append);
    group.add(override);

    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(append);
    radioPanel.add(override);

    // insert sub components
    JLabel label1 = new JLabel(Localization.lang("Available BibTeX fields"));
    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(label1, con);
    inputPanel.add(label1);

    con.gridwidth = GridBagConstraints.REMAINDER;
    con.gridheight = 8;
    con.weighty = 1;
    con.fill = GridBagConstraints.BOTH;
    gbl.setConstraints(fieldScroller, con);
    inputPanel.add(fieldScroller);

    con.fill = GridBagConstraints.HORIZONTAL;
    con.weighty = 0;
    con.gridwidth = 2;
    gbl.setConstraints(radioPanel, con);
    inputPanel.add(radioPanel);

    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(insertButton, con);
    inputPanel.add(insertButton);
    return inputPanel;
}

From source file:com.rapidminer.gui.new_plotter.gui.GlobalConfigurationPanel.java

private void createComponents() {

    // create panel for global configuration

    {//from   w  w w.j  a v a 2  s. c  o m
        // add title label
        JLabel titleLabel = new ResourceLabel("plotter.configuration_dialog.chart_title");

        String title = getPlotConfiguration().getTitleText();
        if (title == null) {
            title = "";
        }

        titleTextField = new JTextField(title);
        titleLabel.setLabelFor(titleTextField);
        titleTextField.addKeyListener(new KeyListener() {

            @Override
            public void keyTyped(KeyEvent e) {
                return;
            }

            @Override
            public void keyReleased(KeyEvent e) {
                String newTitle = titleTextField.getText();
                String titleText = getCurrentPlotInstance().getMasterPlotConfiguration().getTitleText();
                if (titleText != null) {
                    if (!titleText.equals(newTitle) || titleText == null && newTitle.length() > 0) {
                        if (newTitle.length() > 0) {
                            getPlotConfiguration().setTitleText(newTitle);
                        } else {
                            getPlotConfiguration().setTitleText(null);
                        }
                    }
                } else {
                    if (newTitle.length() > 0) {
                        getPlotConfiguration().setTitleText(newTitle);
                    } else {
                        getPlotConfiguration().setTitleText(null);
                    }
                }

                if (newTitle.equals("Iris") && SwingTools.isControlOrMetaDown(e)
                        && e.getKeyCode() == KeyEvent.VK_D) {
                    startAnimation();
                }
            }

            @Override
            public void keyPressed(KeyEvent e) {
                return;
            }
        });
        titleTextField.setPreferredSize(new Dimension(115, 23));

        titleConfigButton = new JToggleButton(new PopupAction(true, "plotter.configuration_dialog.open_popup",
                chartTitleConfigurationContainer, PopupPosition.HORIZONTAL));

        addThreeComponentRow(this, titleLabel, titleTextField, titleConfigButton);
    }

    // add orientation check box
    {
        JLabel plotOrientationLabel = new ResourceLabel(
                "plotter.configuration_dialog.global_config_panel.plot_orientation");

        PlotOrientation[] orientations = { PlotOrientation.HORIZONTAL, PlotOrientation.VERTICAL };
        plotOrientationComboBox = new JComboBox(orientations);
        plotOrientationLabel.setLabelFor(plotOrientationComboBox);
        plotOrientationComboBox.setRenderer(new EnumComboBoxCellRenderer("plotter"));
        plotOrientationComboBox.setSelectedIndex(0);
        plotOrientationComboBox.addPopupMenuListener(new PopupMenuListener() {

            @Override
            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                return;

            }

            @Override
            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                getPlotConfiguration()
                        .setOrientation((PlotOrientation) plotOrientationComboBox.getSelectedItem());
            }

            @Override
            public void popupMenuCanceled(PopupMenuEvent e) {
                return;
            }
        });

        addTwoComponentRow(this, plotOrientationLabel, plotOrientationComboBox);
    }

    // add legend popup button
    {
        JLabel legendStyleConfigureLabel = new ResourceLabel(
                "plotter.configuration_dialog.global_config_panel.legend_style");

        JToggleButton legendStyleConfigButton = new JToggleButton(
                new PopupAction(true, "plotter.configuration_dialog.open_popup", legendConfigContainer,
                        PopupAction.PopupPosition.HORIZONTAL));
        legendStyleConfigureLabel.setLabelFor(legendStyleConfigButton);

        addTwoComponentRow(this, legendStyleConfigureLabel, legendStyleConfigButton);

    }

    // add legend popup button
    {
        JLabel axisStyleConfigureLabel = new ResourceLabel(
                "plotter.configuration_dialog.global_config_panel.axis_style");

        JToggleButton axisStyleConfigureButton = new JToggleButton(
                new PopupAction(true, "plotter.configuration_dialog.open_popup", axisConfigurationContainer,
                        PopupAction.PopupPosition.HORIZONTAL));
        axisStyleConfigureLabel.setLabelFor(axisStyleConfigureButton);

        addTwoComponentRow(this, axisStyleConfigureLabel, axisStyleConfigureButton);
    }

    // add color scheme dialog button
    {
        JLabel colorConfigureLabel = new ResourceLabel(
                "plotter.configuration_dialog.global_config_panel.color_scheme");

        colorsSchemesComboBoxModel = new DefaultComboBoxModel();
        colorSchemesComboBox = new JComboBox(colorsSchemesComboBoxModel);
        colorConfigureLabel.setLabelFor(colorSchemesComboBox);
        colorSchemesComboBox.setRenderer(new ColorSchemeComboBoxRenderer());
        colorSchemesComboBox.addPopupMenuListener(new PopupMenuListener() {

            @Override
            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                return;

            }

            @Override
            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                ColorScheme colorScheme = (ColorScheme) colorSchemesComboBox.getSelectedItem();
                if (colorScheme != null) {
                    getPlotConfiguration().setActiveColorScheme(colorScheme.getName());
                }
            }

            @Override
            public void popupMenuCanceled(PopupMenuEvent e) {
                return;
            }
        });

        JButton colorConfigButton = new JButton(
                new ResourceAction(true, "plotter.configuration_dialog.open_color_scheme_dialog") {

                    private static final long serialVersionUID = 1L;

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

        addThreeComponentRow(this, colorConfigureLabel, colorSchemesComboBox, colorConfigButton);

    }

    // add plot background color
    {
        plotBackGroundColorLabel = new ResourceLabel(
                "plotter.configuration_dialog.global_config_panel.select_plot_background_color");

        plotBackgroundColorChooserButton = new JButton(
                new ResourceAction(true, "plotter.configuration_dialog.select_plot_color") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        createPlotBackgroundColorDialog();

                    }
                });
        plotBackGroundColorLabel.setLabelFor(plotBackgroundColorChooserButton);

        addTwoComponentRow(this, plotBackGroundColorLabel, plotBackgroundColorChooserButton);

    }

    // add chart background color
    {
        frameBackGroundColorLabel = new ResourceLabel(
                "plotter.configuration_dialog.global_config_panel.select_frame_background_color");

        frameBackgroundColorChooserButton = new JButton(
                new ResourceAction(true, "plotter.configuration_dialog.select_frame_color") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        createFrameBackgroundColorDialog();
                    }
                });
        frameBackGroundColorLabel.setLabelFor(frameBackgroundColorChooserButton);

        addTwoComponentRow(this, frameBackGroundColorLabel, frameBackgroundColorChooserButton);

        // GridBagConstraints itemConstraint = new GridBagConstraints();
        // itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        // itemConstraint.weightx = 1.0;
        // this.add(frameBackgroundColorChooserButton, itemConstraint);

    }

    // add spacer panel
    {
        JPanel spacerPanel = new JPanel();
        GridBagConstraints itemConstraint = new GridBagConstraints();
        itemConstraint.fill = GridBagConstraints.BOTH;
        itemConstraint.weightx = 1;
        itemConstraint.weighty = 1;
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        this.add(spacerPanel, itemConstraint);
    }

}