Example usage for com.jgoodies.forms.layout FormLayout FormLayout

List of usage examples for com.jgoodies.forms.layout FormLayout FormLayout

Introduction

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

Prototype

public FormLayout(ColumnSpec[] colSpecs, RowSpec[] rowSpecs) 

Source Link

Document

Constructs a FormLayout using the given column and row specifications.

Usage

From source file:ch.fork.AdHocRailway.ui.turnouts.configuration.TurnoutGroupConfigPanel.java

License:Open Source License

private void buildPanel() {
    initComponents();//from   w  ww.ja v  a  2s  .c  om

    final FormLayout layout = new FormLayout("right:pref, 3dlu, pref:grow", "p:grow, 3dlu");

    final PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();
    final CellConstraints cc = new CellConstraints();

    builder.addLabel("Name", cc.xy(1, 1));
    builder.add(turnoutGroupName, cc.xy(3, 1));
    add(builder.getPanel());
}

From source file:ch.thomasmueller.saltyfiles.ui.ArchivProgressDialog.java

License:Open Source License

/**
 * Returns the layout to be used./*w w  w  .jav  a2s.co m*/
 * @return the layout 
 */
private FormLayout doFormLayout() {

    FormLayout layout = new FormLayout(
            //   columns
            "0dlu, pref, 0dlu",
            //    rows
            "0dlu, p, 2dlu, p, 0dlu");

    return layout;
}

From source file:ch.thomasmueller.saltyfiles.ui.MainView.java

License:Open Source License

/**
 * @return the layout to be used.//from www. j  a  va  2 s.c  o  m
 */
private FormLayout layout() {

    FormLayout layout = new FormLayout("right:70dlu, 3dlu, pref, 3dlu, right:pref, 3dlu, left:3dlu, 3dlu, pref", // columns
            //   general rows
            "p, 3dlu, p, 3dlu, p, 3dlu, p,3dlu p, 9dlu," +
            // encript rows
                    "p, 3dlu, p, 3dlu, p, 3dlu, p,9dlu," +
                    // decript rows
                    "p, 3dlu, p, 3dlu, p, 9dlu," +
                    //       buttonbar row
                    "p, 3dlu,p");

    //       Specify that columns 1 & 5 as well as 3 & 7 have equal widths.
    layout.setColumnGroups(new int[][] { { 1, 5 }, { 3, 7 } });
    return layout;
}

From source file:ch.zhaw.ads.Bla.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - nicam nicamson

    //======== this ========

    // JFormDesigner evaluation mark
    setBorder(//from www .  j a v  a2  s. c o  m
            new javax.swing.border.CompoundBorder(
                    new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                            "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
                            javax.swing.border.TitledBorder.BOTTOM,
                            new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red),
                    getBorder()));
    addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent e) {
            if ("border".equals(e.getPropertyName()))
                throw new RuntimeException();
        }
    });

    setLayout(new FormLayout("default, $lcgap, default", "2*(default, $lgap), default"));
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:ch.zhaw.ias.dito.ui.InputPanel.java

License:BSD License

public InputPanel(HelpArea helpArea) {
    super(ScreenEnum.INPUT, null, ScreenEnum.QUESTION);

    FormLayout layout = new FormLayout(
            "max(30dlu; pref), 30dlu, 5dlu, max(150dlu; pref), 5dlu, max(100dlu; pref), 5dlu, max(50dlu; pref), fill:0:g",
            "pref, 2dlu, pref, 2dlu, pref, 10dlu, pref, 2dlu, 20dlu, 2dlu, fill:pref:grow, 2dlu, pref, 2dlu, pref, 2dlu, pref");
    //layout.setRowGroups(new int[][]{{2, 4, 6}}); 
    CellConstraints cc = new CellConstraints();
    DefaultFormBuilder fb = new DefaultFormBuilder(layout, Translation.INSTANCE.getBundle());

    browseButton = new JXButton(Translation.INSTANCE.get("s1.bu.browse"));
    filePath.setName(Translation.INSTANCE.get("s1.lb.file"));

    fb.addI15dSeparator("s1.title.file", cc.xyw(1, 1, 8));
    fb.add(new HelpLabel(helpArea, "s1.lb.file"), cc.xyw(1, 3, 2));
    fb.add(filePath, cc.xyw(4, 3, 3));//from   w w w .  j a  v a  2s .  c  o m
    fb.add(browseButton, cc.xy(8, 3));
    fb.add(new HelpLabel(helpArea, "s1.lb.separator"), cc.xyw(1, 5, 2));
    //fb.addI15dLabel("s1.lb.separator", cc.xyw(1, 5, 2));
    fb.add(separator, cc.xy(8, 5));

    fb.addI15dSeparator("s1.title.data", cc.xyw(1, 7, 8));

    visualTable = new JXTable(tableModel);
    visualTable.setSortable(false);
    //visualTable.setHorizontalScrollEnabled(true);
    visualTable.getTableHeader().setReorderingAllowed(false);
    visualTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    visualTable.addHighlighter(new ColorHighlighter(new HighlightPredicate() {

        @Override
        public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
            return isColumnSelected(adapter.column) && isRowSelected(adapter.row);
        }
    }, Color.LIGHT_GRAY, Color.BLACK, Color.LIGHT_GRAY, Color.BLACK));
    JScrollPane scrollPane = new JScrollPane(visualTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    rowSlider.setInverted(true);
    rowSlider.setOrientation(JSlider.VERTICAL);
    columnSlider.addChangeListener(this);
    rowSlider.addChangeListener(this);
    columnSlider.setMinimum(1);
    rowSlider.setMinimum(1);

    columnMinSpinner.addChangeListener(this);
    columnMaxSpinner.addChangeListener(this);
    rowMinSpinner.addChangeListener(this);
    rowMaxSpinner.addChangeListener(this);
    separator.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            updateTable();
        }
    });
    filePath.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            updateTable();
        }
    });

    JPanel columnSliderPanel = new JPanel();
    columnSliderPanel.setLayout(new BorderLayout());
    columnMinSpinner.setPreferredSize(new Dimension(50, (int) columnMinSpinner.getPreferredSize().getHeight()));
    columnMaxSpinner.setPreferredSize(new Dimension(50, (int) columnMaxSpinner.getPreferredSize().getHeight()));
    columnSliderPanel.add(columnMinSpinner, BorderLayout.WEST);
    columnSliderPanel.add(columnSlider, BorderLayout.CENTER);
    columnSliderPanel.add(columnMaxSpinner, BorderLayout.EAST);
    fb.add(columnSliderPanel, cc.xyw(4, 9, 6));

    JPanel rowSliderPanel = new JPanel();
    rowSliderPanel.setLayout(new BorderLayout());
    rowSliderPanel.add(rowMinSpinner, BorderLayout.NORTH);
    rowSliderPanel.add(rowSlider, BorderLayout.CENTER);
    rowSliderPanel.add(rowMaxSpinner, BorderLayout.SOUTH);
    fb.add(rowSliderPanel, cc.xyw(2, 11, 1));

    //set preferred size explicitly, otherwise the preferred height is too big and the screen doesn't scale its size in an appropriate way
    scrollPane.setPreferredSize(new Dimension(scrollPane.getWidth(), 100));
    fb.add(scrollPane, cc.xyw(4, 11, 6));
    fb.add(allSurveys, cc.xy(4, 13));
    fb.add(allQuestions, cc.xy(4, 15));
    fb.add(columnTitles, cc.xy(4, 17));

    //validationGroup.add(filePath, Validators.FILE_MUST_BE_FILE, Validators.FILE_MUST_EXIST);
    //validationGroup.add(separator, Validators.REQUIRE_NON_EMPTY_STRING);

    Input i = Config.INSTANCE.getDitoConfig().getInput();
    filePath.setText(i.getFilename());
    separator.setText(Character.toString(i.getSeparator()));
    allQuestions.addChangeListener(this);
    allSurveys.addChangeListener(this);
    columnTitles.addChangeListener(this);
    allQuestions.setSelected(i.isAllQuestions());
    allSurveys.setSelected(i.isAllSurveys());
    columnTitles.setSelected(i.isQuestionTitles());

    browseButton.addActionListener(this);
    this.setLayout(new BorderLayout());
    this.add(fb.getPanel(), BorderLayout.CENTER);
    updateTable();
    columnSlider.setValue(i.getStartQuestion());
    columnSlider.setUpperValue(i.getEndQuestion());
    rowSlider.setValue(i.getStartSurvey());
    rowSlider.setUpperValue(i.getEndSurvey());
}

From source file:ch.zhaw.ias.dito.ui.MainFrame.java

License:BSD License

public MainFrame(String filename) {
    if (filename != null) {
        try {//from w w  w  .ja va 2  s  . co  m
            DitoConfiguration config = DitoConfiguration.loadFromFile(filename);
            config.setLocation(filename);
            config.loadMatrix();
            Config.INSTANCE.setDitoConfig(config);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        Config.INSTANCE.setDitoConfig(DitoConfiguration.createEmpty());
    }

    FormLayout layout = new FormLayout("2dlu, 150dlu, 2dlu, pref:grow, 2dlu",
            "2dlu, fill:75dlu, 2dlu, fill:pref:grow, 2dlu");
    CellConstraints cc = new CellConstraints();
    this.getContentPane().setLayout(layout);

    toolbarPanel = new ToolbarPanel(this);

    this.add(toolbarPanel, cc.xy(2, 2));
    this.add(helpPanel, cc.xy(4, 2));
    this.add(processPanel, cc.xy(2, 4));
    this.add(mainPanel, cc.xy(4, 4));

    this.setTitle(Translation.INSTANCE.get("misc.title") + " (build #" + AppConfig.BUILD_NUMBER + " built on "
            + AppConfig.BUILD_DATE + ")");
    this.setSize(1200, 1000);
    this.setDefaultCloseOperation(JXFrame.EXIT_ON_CLOSE);
    this.setVisible(true);

    switchTo(ScreenEnum.INPUT);
    //save before closing?
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            toolbarPanel.checkSave();
        }
    });
}

From source file:ch.zhaw.ias.dito.ui.MainPanel.java

License:BSD License

public MainPanel(MainFrame mainFrame) {
    this.mainFrame = mainFrame;
    //setTitle(Translation.INSTANCE.get("main.main"));
    setBorder(BorderFactory.createEtchedBorder());

    FormLayout layout = new FormLayout("fill:20dlu, fill:0:grow, fill:20dlu",
            "20dlu, fill:min:grow(0.8), fill:0:grow(0.2), fill:20dlu");
    //layout.setRowGroups(new int[][]{{2, 4, 6}}); 
    CellConstraints cc = new CellConstraints();
    //DefaultFormBuilder fb = new DefaultFormBuilder(layout, Translation.INSTANCE.getBundle(), new FormDebugPanel());

    JXPanel buttonPanel = new JXPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    nextButton.setPreferredSize(new Dimension(100, 25));
    previousButton.setPreferredSize(new Dimension(100, 25));

    buttonPanel.add(previousButton);//w w w .  j  av  a 2 s . c o  m
    buttonPanel.add(nextButton);
    validationPanel.addChangeListener(this);

    this.setLayout(layout);
    this.add(validationPanel, cc.xy(2, 2));
    this.add(buttonPanel, cc.xy(2, 4));

    nextButton.addActionListener(this);
    previousButton.addActionListener(this);
}

From source file:ch.zhaw.ias.dito.ui.MethodPanel.java

License:BSD License

public MethodPanel(HelpArea helpArea) {
    super(ScreenEnum.METHOD, ScreenEnum.QUESTION, ScreenEnum.ANALYSIS);
    comboModel = new MethodComboModel(DistanceMethodEnum.get(Coding.REAL));
    methods = new JComboBox(comboModel);

    FormLayout layout = new FormLayout(
            "pref, 5dlu, max(100dlu; pref), 5dlu, max(100dlu; pref), 5dlu, max(100dlu; pref), pref:grow",
            "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, fill:pref:grow");
    CellConstraints cc = new CellConstraints();
    DefaultFormBuilder fb = new DefaultFormBuilder(layout, Translation.INSTANCE.getBundle());

    fb.addI15dSeparator("s3.lb.method", cc.xyw(1, 1, 5));
    fb.addI15dLabel("s3.lb.coding", cc.xyw(1, 3, 3));
    fb.add(codingGroup, cc.xy(5, 3));//from ww  w.ja  va2 s  . c  o  m
    codingGroup.addActionListener(this);

    fb.addI15dLabel("s3.lb.distance", cc.xyw(1, 5, 3));
    fb.add(methods, cc.xy(5, 5));
    methods.addActionListener(this);

    fb.addI15dLabel("s3.lb.parameter", cc.xyw(1, 7, 3));
    fb.add(parameter, cc.xy(5, 7));

    fb.add(formula, cc.xywh(7, 3, 1, 5));

    fb.add(ownDefinition, cc.xyw(1, 9, 3));
    createDefinition.setText("(a+d)/(a+b+c+d)");
    fb.add(createDefinition, cc.xy(5, 9));

    plotButton.addActionListener(this);
    fb.add(plotButton, cc.xy(5, 11));

    fb.addI15dSeparator("s3.lb.calculation", cc.xyw(1, 13, 5));
    fb.add(randomSample, cc.xyw(1, 15, 5));
    fb.addI15dLabel("s3.lb.sampleSize", cc.xy(3, 17));
    fb.add(sampleSize, cc.xy(5, 17));

    fb.add(parallel, cc.xyw(1, 19, 5));
    fb.addI15dLabel("s3.lb.numberOfThreads", cc.xy(3, 21));
    fb.add(numberOfThreads, cc.xy(5, 21));

    Method m = Config.INSTANCE.getDitoConfig().getMethod();
    codingGroup.setSelectedValue(m.getMethod().getCoding());
    methods.setSelectedItem(DistanceMethodEnum.get(m.getName()));

    randomSample.setSelected(m.isUseRandomSample());
    randomSample.addActionListener(this);
    sampleSize.setText(Integer.toString(m.getSampleSize()));

    parallel.setSelected(m.isParallel());
    parallel.addActionListener(this);
    numberOfThreads.setText(Integer.toString(m.getNumberOfThreads()));

    this.setLayout(new BorderLayout());
    this.add(fb.getPanel(), BorderLayout.CENTER);

    //set distance matrix to null. this way it can be garbage collected
    //the distance matrix is probably quite large, and the calculations will need a lot of memory
    Config.INSTANCE.setDistanceMatrix(null);
    updateEnabling();
}

From source file:ch.zhaw.ias.dito.ui.OutputPanel.java

License:BSD License

public OutputPanel(HelpArea helpArea) {
    super(ScreenEnum.OUTPUT, ScreenEnum.ANALYSIS, null);

    FormLayout layout = new FormLayout(
            "max(50dlu; pref), 5dlu, max(100dlu; pref), 5dlu, max(50dlu; pref), 5dlu, max(100dlu; pref), 5dlu, max(50dlu; pref)",
            "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref");
    //layout.setRowGroups(new int[][]{{2, 4, 6}}); 
    CellConstraints cc = new CellConstraints();
    DefaultFormBuilder fb = new DefaultFormBuilder(layout, Translation.INSTANCE.getBundle());

    browseButton = new JXButton(Translation.INSTANCE.get("s1.bu.browse"));
    filePath.setName(Translation.INSTANCE.get("s1.lb.file"));

    fb.addI15dSeparator("s5.title.file", cc.xyw(1, 1, 9));
    fb.addI15dLabel("s1.lb.file", cc.xy(1, 3));
    fb.add(filePath, cc.xyw(3, 3, 5));//from   w w w .  j  a v  a  2  s .c  o m
    fb.add(browseButton, cc.xy(9, 3));
    fb.addI15dLabel("s1.lb.separator", cc.xy(1, 5));
    fb.add(separator, cc.xy(7, 5));
    fb.addI15dLabel("s5.lb.precision", cc.xy(1, 7));
    fb.add(precision, cc.xy(7, 7));
    fb.add(saveButton, cc.xy(7, 9));

    //validationGroup.add(filePath, Validators.fFILE_MUST_BE_FILE);
    //validationGroup.add(separator, Validators.REQUIRE_NON_EMPTY_STRING);
    Output o = Config.INSTANCE.getDitoConfig().getOutput();
    filePath.setText(o.getFilename());
    separator.setText(Character.toString(o.getSeparator()));
    precision.setText(Integer.toString(o.getPrecision()));

    browseButton.addActionListener(this);
    saveButton.addActionListener(this);
    this.setLayout(new BorderLayout());
    this.add(fb.getPanel(), BorderLayout.CENTER);
}

From source file:ch.zhaw.ias.dito.ui.ProcessPanel.java

License:BSD License

public ProcessPanel() {
    setBorder(BorderFactory.createEtchedBorder());

    FormLayout layout = new FormLayout("5dlu, 50dlu:grow, 5dlu",
            "5dlu, fill:pref, fill:pref:grow, fill:pref, fill:pref:grow, fill:pref, fill:pref:grow, fill:pref, fill:pref:grow, fill:pref, 5dlu, fill:20dlu, 5dlu, fill:8dlu, 5dlu");
    int[][] rowGroups = new int[][] { { 2, 4, 6, 8 }, { 3, 5, 7 } };
    layout.setRowGroups(rowGroups);/*from  w  ww .  ja  v  a 2s. c  o m*/
    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(layout);
    panels.put(ScreenEnum.INPUT,
            new ProcessStepPanel(ScreenEnum.INPUT, ConfigProperty.INPUT_FILENAME, ConfigProperty.INPUT_SIZE));
    panels.put(ScreenEnum.QUESTION, new ProcessStepPanel(ScreenEnum.QUESTION, ConfigProperty.QUESTION_NUMBER));
    panels.put(ScreenEnum.METHOD,
            new ProcessStepPanel(ScreenEnum.METHOD, ConfigProperty.METHOD_NAME, ConfigProperty.RANDOM_SAMPLE));
    panels.put(ScreenEnum.ANALYSIS, new ProcessStepPanel(ScreenEnum.ANALYSIS));
    panels.put(ScreenEnum.OUTPUT, new ProcessStepPanel(ScreenEnum.OUTPUT, ConfigProperty.OUTPUT_FILENAME,
            ConfigProperty.OUTPUT_PRECISION));

    pb.add(panels.get(ScreenEnum.INPUT), cc.xy(2, 2));
    pb.add(new ArrowPanel(), cc.xy(2, 3));
    pb.add(panels.get(ScreenEnum.QUESTION), cc.xy(2, 4));
    pb.add(new ArrowPanel(), cc.xy(2, 5));
    pb.add(panels.get(ScreenEnum.METHOD), cc.xy(2, 6));
    pb.add(new ArrowPanel(), cc.xy(2, 7));
    pb.add(panels.get(ScreenEnum.ANALYSIS), cc.xy(2, 8));
    pb.add(new ArrowPanel(), cc.xy(2, 9));
    pb.add(panels.get(ScreenEnum.OUTPUT), cc.xy(2, 10));

    pb.add(progress, cc.xy(2, 12));
    pb.add(status, cc.xy(2, 14));

    this.setLayout(new BorderLayout());
    add(pb.getPanel(), BorderLayout.CENTER);
    Logger.INSTANCE.addInterface(this);
}