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:com.allenstudio.ir.ui.NoteOperationsPane.java

License:Open Source License

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

    JLabel typeLabel = new JLabel(UIResources.getString("typeLabel") + ":");
    JLabel featureLabel = new JLabel(UIResources.getString("featureLabel") + ":");
    JLabel repetitionLabel = new JLabel(UIResources.getString("repetitionLabel") + ":");
    JLabel moveLabel = new JLabel(UIResources.getString("moveLabel") + ":");

    //======== Panel building ========
    {/*w  w  w.  j  a v a2s  .c om*/
        this.setContentPaneBorder(BorderFactory.createEmptyBorder(8, 2, 8, 3));

        Container thisContentPane = this.getContentPane();

        thisContentPane.setLayout(new FormLayout(
                new ColumnSpec[] { new ColumnSpec("right:max(default;40dlu)"),
                        FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec("max(default;40dlu)") },
                new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC,
                        FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC }));

        //---- typeLabel ----
        thisContentPane.add(typeLabel, cc.xy(1, 1));
        thisContentPane.add(typeBox, cc.xy(3, 1));

        //---- featureLabel ----
        thisContentPane.add(featureLabel, cc.xy(1, 3));

        //---- featureButton ----
        featureButton.setText("F:\\Setup.exe");
        thisContentPane.add(featureButton, cc.xy(3, 3));

        //---- repetitionLabel ----
        thisContentPane.add(repetitionLabel, cc.xy(1, 5));
        thisContentPane.add(repetitionBox, cc.xy(3, 5));

        //---- moveLabel ----
        thisContentPane.add(moveLabel, cc.xy(1, 7));

        //---- datePickButton ----
        datePickButton.setText(UIResources.getString("datePickLabel"));
        thisContentPane.add(datePickButton, cc.xy(3, 7));
    }
}

From source file:com.alternatecomputing.jschnizzle.action.AboutAction.java

License:Apache License

/**
 * create the about panel//from   ww  w. j  a  v  a2  s .c  om
 *
 * @param dialog component that will contain this panel
 * @return about panel
 */
private JPanel createAboutPanel(final JDialog dialog) {
    FormLayout layout = new FormLayout("fill:min:grow, pref", "pref, 4dlu, fill:min:grow, 4dlu, pref");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();
    CellConstraints cc = new CellConstraints();
    JXHeader header = new JXHeader("JSchnizzle", "");
    builder.add(header, cc.xywh(1, 1, 2, 1));
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Version", createVersionPanel());
    tabbedPane.addTab("About", createNoticePanel());
    tabbedPane.addTab("License", createLicensePanel());
    tabbedPane.addTab("Acknowledgements", createAcknowledgementsPanel());
    builder.add(tabbedPane, cc.xywh(1, 3, 2, 1));
    JButton okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });
    builder.add(ButtonBarFactory.buildOKBar(okButton), cc.xy(2, 5));
    return builder.getPanel();
}

From source file:com.alternatecomputing.jschnizzle.action.AboutAction.java

License:Apache License

/**
 * create the panel containing the version information
 *
 * @return version panel/*from   w w  w . jav  a2 s  .  c o  m*/
 */
private Component createVersionPanel() {
    JPanel p = createBasicPanel();
    FormLayout layout = new FormLayout("fill:min:grow, pref, 10dlu, pref, 4dlu, pref, fill:min:grow",
            "fill:min:grow, 20dlu, pref, 4dlu, pref, 4dlu, pref, 20dlu, fill:min:grow");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    CellConstraints cc = new CellConstraints();
    JXImagePanel imagePanel = new JXImagePanel();
    imagePanel.setBackground(Color.WHITE);
    try {
        BufferedImage image = ImageIO
                .read(Thread.currentThread().getContextClassLoader().getResource("logo.jpg"));
        imagePanel.setImage(image);
        imagePanel.setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
    } catch (IOException e) {
        LOGGER.error("Error reading logo image from classpath.", e);
    }
    builder.add(imagePanel, cc.xywh(2, 2, 1, 7));
    Properties buildInfo = getBuildInfo();
    builder.add(new JLabel("Version:"), cc.xy(4, 3));
    builder.add(new JLabel(buildInfo.getProperty("Implementation-Version")), cc.xy(6, 3));
    builder.add(new JLabel("Build Rev:"), cc.xy(4, 5));
    builder.add(new JLabel(buildInfo.getProperty("Implementation-Build")), cc.xy(6, 5));
    builder.add(new JLabel("Build Date:"), cc.xy(4, 7));
    builder.add(new JLabel(buildInfo.getProperty("Implementation-Build-Date").replace("\"", "")), cc.xy(6, 7));
    JPanel panel = builder.getPanel();
    panel.setBackground(Color.WHITE);
    panel.setBorder(BorderFactory.createEtchedBorder());
    p.add(panel, cc.xy(1, 1));
    return p;
}

From source file:com.alternatecomputing.jschnizzle.action.AboutAction.java

License:Apache License

/**
 * create a panel containing content from the given resource location
 *
 * @param resourceLocation location for content
 * @return panel/*  www  . j a v a2  s. co  m*/
 */
private JPanel createBasicPanel() {
    FormLayout layout = new FormLayout("fill:min:grow", "fill:min:grow");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();
    return builder.getPanel();
}

From source file:com.alternatecomputing.jschnizzle.JSchnizzle.java

License:Apache License

private JPanel createMainPanel() {
    JPanel panel = new JXPanel(
            new FormLayout("4dlu, fill:min:grow, 4dlu", "4dlu, fill:min:grow, 4dlu, pref, 4dlu"));
    CellConstraints cc = new CellConstraints();

    JSplitPane verticalSplitPane = UIUtils.createUndecoratedSplitPane(JSplitPane.VERTICAL_SPLIT);
    verticalSplitPane.setDividerLocation(350);
    verticalSplitPane.setResizeWeight(1);
    verticalSplitPane.setDividerSize(8);
    panel.add(verticalSplitPane, cc.xy(2, 2));

    verticalSplitPane.add(createTopSubPanel());

    consoleTextArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(consoleTextArea);
    scrollPane.setPreferredSize(new Dimension(0, 100));
    verticalSplitPane.add(UIUtils.createTitledPanel("Console", scrollPane));

    panel.add(createStatusArea(), cc.xy(2, 4));
    return panel;
}

From source file:com.alternatecomputing.jschnizzle.JSchnizzle.java

License:Apache License

private JPanel createTopSubPanel() {
    mainPanel = new JXPanel(new FormLayout("fill:min:grow", "fill:min:grow"));
    CellConstraints cc = new CellConstraints();

    JSplitPane horizontalSplitPane = UIUtils.createUndecoratedSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    horizontalSplitPane.setDividerLocation(200);
    horizontalSplitPane.setDividerSize(8);
    mainPanel.add(horizontalSplitPane, cc.xy(1, 1));

    JXTaskPaneContainer taskPaneContainer = new JXTaskPaneContainer();

    activityScriptsList = createScriptsList(applicationModel.getActivityScriptsModel(), mainPanel);
    JXTaskPane activityTaskPane = new JXTaskPane();
    activityTaskPane.setTitle("Activity Diagrams");
    activityTaskPane.setToolTipText("Activity Diagram Definitions");
    activityTaskPane.add(activityScriptsList);
    activityTaskPane.getContentPane().setBackground(Color.WHITE);
    MouseAdapter activityMouseAdapter = createDefinitionsMouseAdapter(DiagramType.Activity, mainPanel,
            activityScriptsList);//from   w  w  w .  j a v  a 2  s.c o m
    activityScriptsList.addMouseListener(activityMouseAdapter);
    activityTaskPane.addMouseListener(activityMouseAdapter);
    taskPaneContainer.add(activityTaskPane);

    classScriptsList = createScriptsList(applicationModel.getClassScriptsModel(), mainPanel);
    JXTaskPane classTaskPane = new JXTaskPane();
    classTaskPane.setTitle("Class Diagrams");
    classTaskPane.setToolTipText("Class Diagram Definitions");
    classTaskPane.add(classScriptsList);
    classTaskPane.getContentPane().setBackground(Color.WHITE);
    MouseAdapter classMouseAdapter = createDefinitionsMouseAdapter(DiagramType.Class, mainPanel,
            classScriptsList);
    classScriptsList.addMouseListener(classMouseAdapter);
    classTaskPane.addMouseListener(classMouseAdapter);
    taskPaneContainer.add(classTaskPane);

    useCaseScriptsList = createScriptsList(applicationModel.getUseCaseScriptsModel(), mainPanel);
    JXTaskPane useCaseTaskPane = new JXTaskPane();
    useCaseTaskPane.setTitle("Use Case Diagrams");
    useCaseTaskPane.setToolTipText("Use Case Diagram Definitions");
    useCaseTaskPane.add(useCaseScriptsList);
    useCaseTaskPane.getContentPane().setBackground(Color.WHITE);
    MouseAdapter useCaseMouseAdapter = createDefinitionsMouseAdapter(DiagramType.UseCase, mainPanel,
            useCaseScriptsList);
    useCaseScriptsList.addMouseListener(useCaseMouseAdapter);
    useCaseTaskPane.addMouseListener(useCaseMouseAdapter);
    taskPaneContainer.add(useCaseTaskPane);

    sequenceScriptsList = createScriptsList(applicationModel.getSequenceScriptsModel(), mainPanel);
    JXTaskPane sequenceTaskPane = new JXTaskPane();
    sequenceTaskPane.setTitle("Sequence Diagrams");
    sequenceTaskPane.setToolTipText("Sequence Diagram Definitions");
    sequenceTaskPane.add(sequenceScriptsList);
    sequenceTaskPane.getContentPane().setBackground(Color.WHITE);
    MouseAdapter sequenceMouseAdapter = createDefinitionsMouseAdapter(DiagramType.Sequence, mainPanel,
            sequenceScriptsList);
    sequenceScriptsList.addMouseListener(sequenceMouseAdapter);
    sequenceTaskPane.addMouseListener(sequenceMouseAdapter);
    taskPaneContainer.add(sequenceTaskPane);

    horizontalSplitPane.add(UIUtils.createTitledPanel("Definitions", new JScrollPane(taskPaneContainer)));

    imagePanel = new ImagePanel();
    imagePanel.addDiagramPanelMouseListener(createImagePanelMouseAdapter());
    horizontalSplitPane.add(UIUtils.createTitledPanel("Diagram", imagePanel));

    return mainPanel;
}

From source file:com.alternatecomputing.jschnizzle.JSchnizzle.java

License:Apache License

private Component createStatusArea() {
    JPanel panel = new JXPanel(new FormLayout("fill:min:grow, 4dlu, pref", "pref"));
    CellConstraints cc = new CellConstraints();
    JLabel status = new JLabel(" ");
    status.setBorder(BorderFactory.createEtchedBorder());
    panel.add(status, cc.xy(1, 1));/*from  www  . ja  v a  2  s .  com*/
    progressBar = new JProgressBar();
    panel.add(progressBar, cc.xy(3, 1));
    return panel;
}

From source file:com.alternatecomputing.jschnizzle.ui.ImagePanel.java

License:Apache License

public ImagePanel() {
    super();/*from   w  w  w.j a  va2 s  .c o  m*/
    this.setLayout(new FormLayout("fill:min:grow, pref, 4dlu, pref, 4dlu", "fill:min:grow, 4dlu, pref, 4dlu"));
    CellConstraints cc = new CellConstraints();
    this.diagramPanel = new JPanel();
    this.diagramPanel.setLayout(new BorderLayout());
    this.diagramPanel.setBackground(Color.WHITE);
    JScrollPane jScrollPane = new JScrollPane(diagramPanel);
    add(jScrollPane, cc.xywh(1, 1, 5, 1));
    add(new JLabel("Scale:"), cc.xy(2, 3));
    scaleSlider = createScaleSlider(this);
    add(scaleSlider, cc.xy(4, 3));
}

From source file:com.alternatecomputing.jschnizzle.util.UIUtils.java

License:Apache License

/**
 * create a diagram panel// w  ww  . j a v  a2s  . c  om
 *
 * @param header header for the panel
 * @param diagram model to be bound to the UI
 * @param dialog component that this panel will be embedded into
 * @param isNew whether this will be used for a new diagram or to update an existing one
 * @return diagram panel
 */
public static JPanel createDiagramPanel(JXHeader header, final Diagram diagram, final JDialog dialog,
        final boolean isNew) {
    final String originalScript = diagram.getScript();
    final DiagramStyle originalStyle = diagram.getStyle();
    FormLayout layout = new FormLayout("right:max(40dlu;pref), 4dlu, fill:min:grow",
            "pref, 4dlu, pref, 4dlu, pref, 4dlu, pref, 4dlu, pref, fill:pref:grow, 4dlu, pref");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();
    CellConstraints cc = new CellConstraints();
    builder.add(header, cc.xywh(1, 1, 3, 1));
    builder.add(new JLabel("Name:"), cc.xy(1, 3));
    final JTextField nameTextField = new JTextField(diagram.getName() == null ? "" : diagram.getName());
    builder.add(nameTextField, cc.xy(3, 3));

    builder.add(new JLabel("Note:"), cc.xy(1, 5));
    final JTextField noteTextField = new JTextField(diagram.getNote() == null ? "" : diagram.getNote());
    builder.add(noteTextField, cc.xy(3, 5));

    builder.add(new JLabel("Style:"), cc.xy(1, 7));
    Renderer renderer = RendererFactory.getRendererForDiagram(diagram);
    final JComboBox<DiagramStyle> styleComboBox = new JComboBox<DiagramStyle>(
            renderer.getStylesForType(diagram.getType()));
    if (originalScript != null) {
        styleComboBox.setSelectedItem(originalStyle);
    } else {
        styleComboBox.setSelectedIndex(0);
    }
    builder.add(styleComboBox, cc.xy(3, 7));

    builder.add(new JLabel("Script:"), cc.xy(1, 9));
    final JTextArea scriptTextArea = new JTextArea(diagram.getScript() == null ? "" : diagram.getScript());
    builder.add(new JScrollPane(scriptTextArea), cc.xywh(3, 9, 1, 2));

    JButton okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            diagram.setName(nameTextField.getText());
            diagram.setNote(noteTextField.getText());
            diagram.setStyle((DiagramStyle) styleComboBox.getSelectedItem());
            diagram.setScript(scriptTextArea.getText());
            Dispatcher.dispatchEvent(new JSEvent(EventType.ProgressStarted, null, null));
            Thread t = new Thread() {
                public void run() {
                    try {
                        if (needsRendering()) {
                            LOGGER.info("Rendering diagram '" + diagram.getName() + "'...");
                            Renderer renderer = RendererFactory.getRendererForDiagram(diagram);
                            BufferedImage image = renderer.render(diagram);
                            diagram.nonBeanImage(image);
                            LOGGER.info("Diagram '" + diagram.getName() + "' successfully rendered.");
                        }
                        if (isNew) {
                            LOGGER.info("Diagram '" + diagram.getName() + "' created.");
                            Dispatcher.dispatchEvent(new JSEvent(EventType.DiagramAdded, this, diagram));
                            Dispatcher.dispatchEvent(new JSEvent(EventType.SelectDiagram, this, diagram));
                        } else {
                            LOGGER.info("Diagram '" + diagram.getName() + "' modified.");
                            Dispatcher.dispatchEvent(new JSEvent(EventType.DiagramModified, this, diagram));
                        }
                    } catch (Exception e) {
                        LOGGER.error("Error processing user action.", e);
                    } finally {
                        Dispatcher.dispatchEvent(new JSEvent(EventType.ProgressCompleted, null, null));
                    }
                }

                private boolean needsRendering() {
                    return (!diagram.getScript().equals(originalScript))
                            || (!diagram.getStyle().equals(originalStyle));
                }
            };
            t.start();
            dialog.dispose();
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });
    builder.add(ButtonBarFactory.buildOKCancelBar(okButton, cancelButton), cc.xy(3, 12));
    return builder.getPanel();
}

From source file:com.antelink.sourcesquare.gui.view.SourceSquareView.java

License:Open Source License

/**
 * Create the frame.//  w  ww  . j a v  a  2 s  .c o  m
 */
public SourceSquareView() {
    setIconImage(Toolkit.getDefaultToolkit().getImage(SourceSquareView.class.getResource("/antelink.png")));
    setTitle("SourceSquare");
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 443, 272);
    this.contentPane = new JPanel();
    this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    this.contentPane.setBackground(Color.WHITE);
    setContentPane(this.contentPane);

    this.mainPanel = new JPanel();
    this.mainPanel.setBackground(Color.WHITE);
    GroupLayout gl_contentPane = new GroupLayout(this.contentPane);
    gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addComponent(this.mainPanel, GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE));
    gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addComponent(this.mainPanel, GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE));
    this.mainPanel.setLayout(new BoxLayout(this.mainPanel, BoxLayout.Y_AXIS));

    Image logo;
    JPanel imgPanel = new JPanel();
    imgPanel.setBackground(Color.WHITE);
    this.mainPanel.add(imgPanel, "2, 4, 3, 1, fill, fill");
    logo = Toolkit.getDefaultToolkit()
            .getImage(SourceSquareView.class.getResource("/logo-SourceSquare-400-117.png"));
    JLabel picLabel = new JLabel(new ImageIcon(logo));
    imgPanel.add(picLabel, "2, 2, fill, fill");

    JPanel top = new JPanel();
    top.setBackground(Color.WHITE);
    this.mainPanel.add(top);
    top.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));

    this.textField = new JTextField();
    this.textField.setText("Select a Directory to scan");
    top.add(this.textField, "2, 2, fill, default");
    this.textField.setColumns(10);

    Image selectButtonImage = Toolkit.getDefaultToolkit()
            .getImage(SourceSquareView.class.getResource("/SelectButton.png"));
    this.selectButtonLabel = new JLabel(new ImageIcon(selectButtonImage));
    this.selectButtonLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    top.add(this.selectButtonLabel, "4, 2");

    JPanel panel = new JPanel();
    panel.setBackground(Color.WHITE);
    top.add(panel, "2, 4, 3, 1, fill, fill");

    Image scanButtonImage = Toolkit.getDefaultToolkit()
            .getImage(SourceSquareView.class.getResource("/ScanButton.png"));
    this.scanButtonLabel = new JLabel(new ImageIcon(scanButtonImage));
    this.scanButtonLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    panel.add(this.scanButtonLabel);

    JPanel bottom = new CopyrightPanel();
    bottom.setBackground(Color.WHITE);
    this.mainPanel.add(bottom);
    this.contentPane.setLayout(gl_contentPane);

    setLocationRelativeTo(null);
}