Example usage for com.jgoodies.forms.layout CellConstraints xy

List of usage examples for com.jgoodies.forms.layout CellConstraints xy

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout CellConstraints xy.

Prototype

public CellConstraints xy(int col, int row) 

Source Link

Document

Sets column and row origins; sets width and height to 1; uses the default alignments.

Examples:

 cc.xy(1, 1); cc.xy(1, 3); 

Usage

From source file:ca.phon.app.log.BufferWindow.java

License:Open Source License

private void init() {
    setLayout(new BorderLayout());

    final DialogHeader header = new DialogHeader("Buffers", "");
    add(header, BorderLayout.NORTH);

    final JPanel centerPanel = new JPanel(new BorderLayout());
    final JPanel selectionPanel = new JPanel(new FormLayout("pref, 3dlu, fill:pref:grow, 3dlu, pref", "pref"));
    final CellConstraints cc = new CellConstraints();
    selectionPanel.add(new JLabel("Buffer: "), cc.xy(1, 1));
    buffersBox = new JComboBox();
    buffersBox.addItemListener(new ItemListener() {

        @Override/*from  www.  j a  v  a 2  s . c  om*/
        public void itemStateChanged(ItemEvent e) {
            final String bufferName = e.getItem().toString();
            selectBuffer(bufferName);
        }

    });
    selectionPanel.add(buffersBox, cc.xy(3, 1));

    closeButton = new JButton(new CloseCurrentBufferAction());
    selectionPanel.add(closeButton, cc.xy(5, 1));

    centerPanel.add(selectionPanel, BorderLayout.NORTH);

    buffersPanel = new JPanel(buffersLayout);
    centerPanel.add(buffersPanel, BorderLayout.CENTER);

    add(centerPanel, BorderLayout.CENTER);
}

From source file:ca.phon.app.opgraph.syllabifier.SyllabifierSettingsPanel.java

License:Open Source License

private void init() {
    final FormLayout layout = new FormLayout("right:pref, 3dlu, fill:pref:grow", "pref, 3dlu, pref");
    setLayout(layout);/*w w  w .j  a  va2 s.  co  m*/

    final CellConstraints cc = new CellConstraints();

    add(new JLabel("Syllabifier name:"), cc.xy(1, 1));
    nameField = new JTextField();
    add(nameField, cc.xy(3, 1));

    add(new JLabel("Syllabifier language:"), cc.xy(1, 3));
    languageField = new JTextField();
    add(languageField, cc.xy(3, 3));
}

From source file:ca.phon.app.prefs.EditorPrefsPanel.java

License:Open Source License

private void init() {

    CellConstraints cc = new CellConstraints();

    final IPADictionaryLibrary dictLibrary = IPADictionaryLibrary.getInstance();

    final String dictLangPref = PrefHelper.get(PhonProperties.IPADICTIONARY_LANGUAGE,
            PhonProperties.DEFAULT_IPADICTIONARY_LANGUAGE);
    final Language dictLang = Language.parseLanguage(dictLangPref);
    Language langs[] = dictLibrary.availableLanguages().toArray(new Language[0]);
    Arrays.sort(langs, new LanguageComparator());
    cmbDictionaryLanguage = new JComboBox<>(langs);
    cmbDictionaryLanguage.setSelectedItem(dictLang);
    cmbDictionaryLanguage.addItemListener(new DictionaryLanguageListener());
    cmbDictionaryLanguage.setRenderer(new LanguageCellRenderer());

    JPanel jpanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    jpanel1.setBorder(new TitledBorder("Dictionary Language"));
    jpanel1.add(cmbDictionaryLanguage);// w  ww .  j  av a  2 s  .  c  o m

    final SyllabifierLibrary syllabifierLibrary = SyllabifierLibrary.getInstance();

    final Language syllLangPref = syllabifierLibrary.defaultSyllabifierLanguage();

    Syllabifier defSyllabifier = null;
    final Iterator<Syllabifier> syllabifiers = syllabifierLibrary.availableSyllabifiers();
    List<Syllabifier> sortedSyllabifiers = new ArrayList<Syllabifier>();
    while (syllabifiers.hasNext()) {
        final Syllabifier syllabifier = syllabifiers.next();
        if (syllabifier.getLanguage().equals(syllLangPref))
            defSyllabifier = syllabifier;
        sortedSyllabifiers.add(syllabifier);
    }
    Collections.sort(sortedSyllabifiers, new SyllabifierComparator());

    cmbSyllabifierLanguage = new JComboBox<>(sortedSyllabifiers.toArray(new Syllabifier[0]));
    cmbSyllabifierLanguage.setRenderer(new SyllabifierCellRenderer());
    if (defSyllabifier != null)
        cmbSyllabifierLanguage.setSelectedItem(defSyllabifier);
    cmbSyllabifierLanguage.addItemListener(new SyllabifierLanguageListener());

    JPanel jpanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    jpanel2.setBorder(new TitledBorder("Syllabifier Language"));
    jpanel2.add(cmbSyllabifierLanguage);

    autosaveBox = new JComboBox<>(autosaveTimes);

    final Integer autosavePref = PrefHelper.getInt(PhonProperties.AUTOSAVE_INTERVAL,
            PhonProperties.DEFAULT_AUTOSAVE_INTERVAL);
    autosaveBox.setSelectedItem((autosavePref / 60));

    autosaveBox.addItemListener(new AutosaveTimeListener());
    autosaveBox.setRenderer(new AutosaveTimeRenderer());

    JPanel jpanel4 = new JPanel(new FlowLayout(FlowLayout.LEFT));

    jpanel4.add(autosaveBox);
    jpanel4.setBorder(BorderFactory.createTitledBorder("Autosave Sessions"));

    final PhonUIAction backupAct = new PhonUIAction(this, "toggleBackupWhenSave");
    backupAct.putValue(PhonUIAction.NAME,
            "Backup session file to <project>" + File.separator + "backups.zip when saving sessions.");
    backupAct.putValue(PhonUIAction.SELECTED_KEY,
            PrefHelper.getBoolean(SessionEditor.BACKUP_WHEN_SAVING, true));
    backupWhenSaveBox = new JCheckBox(backupAct);

    JPanel jpanel5 = new JPanel(new FlowLayout(FlowLayout.LEFT));

    jpanel5.add(backupWhenSaveBox);
    jpanel5.setBorder(BorderFactory.createTitledBorder("Backup Sessions"));

    JPanel innerPanel = new JPanel();
    FormLayout layout = new FormLayout("fill:pref:grow", "pref, pref, pref, pref, pref");
    innerPanel.setLayout(layout);

    innerPanel.add(jpanel1, cc.xy(1, 1));
    innerPanel.add(jpanel2, cc.xy(1, 2));
    innerPanel.add(jpanel4, cc.xy(1, 4));
    innerPanel.add(jpanel5, cc.xy(1, 5));

    setLayout(new BorderLayout());
    JScrollPane innerScroller = new JScrollPane(innerPanel);
    add(innerScroller, BorderLayout.CENTER);
}

From source file:ca.phon.app.prefs.GeneralPrefsPanel.java

License:Open Source License

private void init() {
    CellConstraints cc = new CellConstraints();

    // update checking
    boolean doCheckUpdate = PrefHelper.getBoolean(checkForUpdateAtStartupProp, true);

    JCheckBox checkForUpdatesBox = new JCheckBox("Check for updates when application starts");
    checkForUpdatesBox.setSelected(doCheckUpdate);
    checkForUpdatesBox.addChangeListener(new ChangeListener() {

        @Override/* ww w  .j  a  v a  2  s. c o m*/
        public void stateChanged(ChangeEvent e) {
            JCheckBox box = (JCheckBox) e.getSource();
            boolean doCheckUpdate = box.isSelected();
            PrefHelper.getUserPreferences().putBoolean(checkForUpdateAtStartupProp, doCheckUpdate);
        }

    });

    JPanel updatesPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    FormLayout layout = new FormLayout("fill:pref:grow", "pref, pref");
    JPanel innerPanel = new JPanel(layout);
    updatesPanel.add(checkForUpdatesBox);
    updatesPanel.setBorder(BorderFactory.createTitledBorder("Program Updates"));
    innerPanel.add(updatesPanel, cc.xy(1, 1));

    // info messages
    PhonUIAction resetInfoMessagesAct = new PhonUIAction(this, "onResetInfoMessages");
    resetInfoMessagesAct.putValue(Action.NAME, "Reset Information Messages");
    JButton resetInfoMessagesBtn = new JButton(resetInfoMessagesAct);

    JPanel resetPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    resetPanel.add(resetInfoMessagesBtn);
    resetPanel.setBorder(BorderFactory.createTitledBorder("Information Messages"));
    innerPanel.add(resetPanel, cc.xy(1, 2));

    // UI theme

    JScrollPane innerScroller = new JScrollPane(innerPanel);
    setLayout(new BorderLayout());
    add(innerScroller, BorderLayout.CENTER);
}

From source file:ca.phon.app.prefs.MediaPrefsPanel.java

License:Open Source License

private void init() {
    List<String> mediaPaths = MediaLocator.getMediaIncludePaths();
    pathListPanel = new PathListPanel(mediaPaths);
    pathListPanel.addPropertyChangeListener(PathListPanel.PATH_LIST_CHANGED_PROP, new PropertyChangeListener() {

        @Override/*w  ww.j  a  va2  s .c o  m*/
        public void propertyChange(PropertyChangeEvent evt) {
            MediaLocator.setMediaIncludePaths(pathListPanel.getPaths());
        }
    });

    String mediaLblTxt = "<html>" + "<p>The default location for media is the project's __res/media folder.<br>"
            + "Phon will search the default media folder followed by the paths listed below if the<br> full path to media is not specified in Session Information.</p>"
            + "" + "</html>";

    JPanel mediaPathPanel = new JPanel(new BorderLayout());
    mediaPathPanel.add(new JLabel(mediaLblTxt), BorderLayout.NORTH);
    mediaPathPanel.add(pathListPanel);

    mediaPathPanel.setBorder(BorderFactory.createTitledBorder("Media Folders"));

    FormLayout layout = new FormLayout("fill:pref:grow", "pref");
    CellConstraints cc = new CellConstraints();
    setLayout(layout);

    add(mediaPathPanel, cc.xy(1, 1));
}

From source file:ca.phon.app.prefs.PathListPanel.java

License:Open Source License

private void init() {
    setLayout(new BorderLayout());

    FormLayout layout = new FormLayout("fill:pref:grow, pref, pref, pref",
            "pref, pref, pref, pref, fill:pref:grow");
    CellConstraints cc = new CellConstraints();
    setLayout(layout);/*from   w  ww.  j  av a 2  s  . c  o  m*/

    pathList = new JList(new PathListModel());
    pathList.setVisibleRowCount(6);
    JScrollPane pathScroller = new JScrollPane(pathList);

    add(pathScroller, cc.xywh(1, 2, 3, 4));
    add(getMoveUpButton(), cc.xy(4, 2));
    add(getMoveDownButton(), cc.xy(4, 3));
    add(getRemovePathButton(), cc.xy(2, 1));

    add(getAddPathButton(), cc.xy(3, 1));
}

From source file:ca.phon.app.project.checkwizard.CheckWizardStep1.java

License:Open Source License

private void init() {
    setLayout(new BorderLayout());

    header = new DialogHeader("Check Transcriptions", "Select sessions and operations to perform.");
    add(header, BorderLayout.NORTH);

    JPanel topPanel = new JPanel();
    FormLayout topLayout = new FormLayout("20px, pref, pref:grow", "pref, pref, pref, pref, pref");
    CellConstraints cc = new CellConstraints();
    topPanel.setLayout(topLayout);//  ww  w .java2 s .com

    final SyllabifierLibrary library = SyllabifierLibrary.getInstance();
    final Iterator<Syllabifier> syllabifiers = library.availableSyllabifiers();
    final List<Syllabifier> orderedSyllabifiers = new ArrayList<Syllabifier>();
    while (syllabifiers.hasNext())
        orderedSyllabifiers.add(syllabifiers.next());
    Collections.sort(orderedSyllabifiers, new SyllabifierComparator());

    syllabifierList = new JComboBox(orderedSyllabifiers.toArray(new Syllabifier[0]));
    syllabifierList.setEnabled(false);
    syllabifierList.setRenderer(new SyllabifierCellRenderer());

    final String preferredSyllabifier = PrefHelper.get(PhonProperties.SYLLABIFIER_LANGUAGE,
            PhonProperties.DEFAULT_SYLLABIFIER_LANGUAGE);
    syllabifierList.setSelectedItem(preferredSyllabifier);

    checkIPAButton = new JRadioButton("Check IPA Tiers");
    checkIPAButton.setToolTipText("Check IPA tiers for invalid transcriptions.");
    resetSyllabificationButton = new JRadioButton("Reset syllabification");

    resetSyllabificationButton.setToolTipText("Reset syllabification for all IPA tiers in selected sessions.");
    resetAlignmentBox = new JCheckBox("also reset phone alignment");
    resetAlignmentBox.setEnabled(false);

    resetAlignmentButton = new JRadioButton("Reset phone alignment");
    resetAlignmentButton.setToolTipText("Reset alignment for all records in selected sessions.");

    ButtonGroup btnGroup = new ButtonGroup();
    btnGroup.add(checkIPAButton);
    btnGroup.add(resetSyllabificationButton);
    btnGroup.add(resetAlignmentButton);

    resetSyllabificationButton.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent arg0) {
            resetAlignmentBox.setEnabled(resetSyllabificationButton.isSelected());
            syllabifierList.setEnabled(resetSyllabificationButton.isSelected());
        }
    });

    checkIPAButton.setSelected(true);

    topPanel.add(checkIPAButton, cc.xyw(1, 1, 3));
    topPanel.add(resetSyllabificationButton, cc.xyw(1, 2, 2));
    topPanel.add(syllabifierList, cc.xy(3, 2));
    topPanel.add(resetAlignmentBox, cc.xy(2, 4));
    topPanel.add(resetAlignmentButton, cc.xyw(1, 5, 3));

    topPanel.setBorder(BorderFactory.createTitledBorder("Operation"));

    JPanel centerPanel = new JPanel(new BorderLayout());
    sessionSelector = new SessionSelector(project);
    sessionSelector.setVisibleRowCount(20);
    centerPanel.add(new JScrollPane(sessionSelector), BorderLayout.CENTER);

    centerPanel.setBorder(BorderFactory.createTitledBorder("Select sessions"));

    JPanel innerPanel = new JPanel(new BorderLayout());
    innerPanel.add(topPanel, BorderLayout.NORTH);
    innerPanel.add(centerPanel, BorderLayout.CENTER);

    super.add(innerPanel, BorderLayout.CENTER);
}

From source file:ca.phon.app.project.CopySessionEP.java

License:Open Source License

private void begin() {
    if (project1 == null || project2 == null || corpus1 == null || corpus2 == null || session == null) {
        final CopySessionForm csf = new CopySessionForm();

        if (project1 != null)
            csf.setSelectedProject(project1);

        if (corpus1 != null)
            csf.setSelectedCorpus(corpus1);

        if (session != null)
            csf.setSelectedSession(session);

        if (project2 != null)
            csf.setDestinationProject(project2);

        if (corpus2 != null)
            csf.setSelectedCorpus(corpus2);

        // show the window
        String titleString = (move ? "Move " : "Copy ") + "Session";
        final CommonModuleFrame dialog = new CommonModuleFrame(titleString);

        // setup display
        FormLayout layout = new FormLayout("fill:pref:grow, right:pref",
                "pref, 3dlu, fill:pref:grow, 3dlu, pref, 5dlu");
        dialog.getContentPane().setLayout(layout);

        DialogHeader header = new DialogHeader(titleString, "");
        JButton okButton = new JButton("OK");
        okButton.addActionListener(new ActionListener() {

            @Override//from   w w w  . j  a  v a2 s  .  c om
            public void actionPerformed(ActionEvent e) {
                dialog.setVisible(false);
                dialog.dispose();

                // copy the session
                copySession(csf.getSelectedProject(), csf.getDestinationProject(), csf.getSelectedCorpus(),
                        csf.getDestinationCorpus(), csf.getSelectedSession(), force);
            }

        });

        JButton cancelButton = new JButton("Cancel");
        cancelButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                dialog.setVisible(false);
                dialog.dispose();
            }

        });

        CellConstraints cc = new CellConstraints();
        dialog.getContentPane().add(header, cc.xyw(1, 1, 2));
        dialog.getContentPane().add(csf, cc.xyw(1, 3, 2));

        dialog.getContentPane().add(ButtonBarBuilder.buildOkCancelBar(okButton, cancelButton), cc.xy(2, 5));

        dialog.getRootPane().setDefaultButton(okButton);

        dialog.pack();
        dialog.setVisible(true);
    } else {
        // we have enough info, don't show dialog
        copySession(project1, project2, corpus1, corpus2, session, force);
    }
}

From source file:ca.phon.app.project.CopySessionForm.java

License:Open Source License

private void init() {
    // setup layout
    FormLayout layout = new FormLayout("5dlu, pref, 3dlu, fill:pref:grow, 5dlu",
            "5dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 5dlu, pref, 3dlu, pref, 3dlu, pref, 5dlu");
    CellConstraints cc = new CellConstraints();

    this.setLayout(layout);

    // create components
    final List<Project> openProjects = Workspace.userWorkspace().getProjects();

    sessionCombo = new JComboBox();

    corpus1Combo = new JComboBox();
    corpus1Combo.addItemListener(new ItemListener() {

        @Override//w w  w .  j  a  v a2  s .c o  m
        public void itemStateChanged(ItemEvent e) {
            fillSessionList();
        }

    });
    corpus2Combo = new JComboBox();

    proj1Combo = new JComboBox(openProjects.toArray());
    proj1Combo.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            fillCorpusList(proj1Combo);
        }

    });
    proj1Combo.setSelectedIndex(0);

    fillCorpusList(proj1Combo);
    fillSessionList();

    proj2Combo = new JComboBox(openProjects.toArray());
    proj2Combo.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            fillCorpusList(proj2Combo);
        }

    });
    proj2Combo.setSelectedIndex(0);

    fillCorpusList(proj2Combo);

    // add components
    this.add(DefaultComponentFactory.getInstance().createSeparator("Selection"), cc.xyw(2, 2, 3));
    this.add(new JLabel("Project"), cc.xy(2, 4));
    this.add(proj1Combo, cc.xy(4, 4));

    this.add(new JLabel("Corpus"), cc.xy(2, 6));
    this.add(corpus1Combo, cc.xy(4, 6));

    this.add(new JLabel("Session"), cc.xy(2, 8));
    this.add(sessionCombo, cc.xy(4, 8));

    this.add(DefaultComponentFactory.getInstance().createSeparator("Destination"), cc.xyw(2, 10, 3));
    this.add(new JLabel("Project"), cc.xy(2, 12));
    this.add(proj2Combo, cc.xy(4, 12));

    this.add(new JLabel("Corpus"), cc.xy(2, 14));
    this.add(corpus2Combo, cc.xy(4, 14));
}

From source file:ca.phon.app.project.mergewizard.MergeSessionStep1.java

License:Open Source License

private void init() {
    setLayout(new BorderLayout());

    header = new DialogHeader("Merge Sessions", "Specify merged session name, corpus, and sessions for merge.");
    add(header, BorderLayout.NORTH);

    FormLayout formLayout = new FormLayout("right:pref, 3dlu, fill:pref:grow", "pref, 3dlu, pref");
    CellConstraints cc = new CellConstraints();

    JPanel namePanel = new JPanel();
    namePanel.setBorder(BorderFactory.createTitledBorder("Session name and corpus"));
    namePanel.setLayout(formLayout);//  w ww . j a  v a  2 s.c om

    sessionNameField = new JTextField();
    sessionNameField.setText(mergedSessionPrefix);
    namePanel.add(new JLabel("Session name"), cc.xy(1, 1));
    namePanel.add(sessionNameField, cc.xy(3, 1));

    corpusNameField = new JTextField();
    corpusNameField.setText(defaultMergeCorpus);
    namePanel.add(new JLabel("Corpus"), cc.xy(1, 3));
    namePanel.add(corpusNameField, cc.xy(3, 3));

    JPanel centerPanel = new JPanel(new BorderLayout());
    centerPanel.add(namePanel, BorderLayout.NORTH);

    JPanel sessionSelectorPanel = new JPanel(new BorderLayout());
    sessionSelectorPanel.setBorder(BorderFactory.createTitledBorder("Selection sessions"));

    sessionSelector = new SessionSelector(project);
    sessionSelectorPanel.add(new JScrollPane(sessionSelector), BorderLayout.CENTER);

    centerPanel.add(sessionSelectorPanel, BorderLayout.CENTER);
    add(centerPanel, BorderLayout.CENTER);
}