Package javax.swing

Examples of javax.swing.SpringLayout$SpringProxy


    add(panelA, "A");

    JPanel panel = new JPanel();

    SpringLayout layout = new SpringLayout();
    panel.setLayout(layout);

    layout.putConstraint(NORTH, lblRefresh, 5, NORTH, panel);
    layout.putConstraint(NORTH, spnRefresh, 5, SOUTH, lblRefresh);
    layout.putConstraint(NORTH, lblSeconds, 5, SOUTH, spnRefresh);
    layout.putConstraint(NORTH, lblRules, 5, SOUTH, lblSeconds);
    layout.putConstraint(NORTH, scrollRules, 5, SOUTH, lblRules);
    layout.putConstraint(SOUTH, scrollRules, -5, NORTH, btnAddRule);
    layout.putConstraint(SOUTH, btnAddRule, -5, SOUTH, panel);
    layout.putConstraint(SOUTH, btnRemoveRule, -5, SOUTH, panel);

    layout.putConstraint(WEST, lblRefresh, 5, WEST, panel);
    layout.putConstraint(WEST, spnRefresh, 5, WEST, panel);
    layout.putConstraint(WEST, lblSeconds, 5, WEST, panel);
    layout.putConstraint(WEST, lblRules, 5, WEST, panel);
    layout.putConstraint(WEST, scrollRules, 5, WEST, panel);
    layout.putConstraint(EAST, scrollRules, -5, EAST, panel);
    layout.putConstraint(WEST, btnAddRule, 5, WEST, panel);
    layout.putConstraint(WEST, btnRemoveRule, 5, EAST, btnAddRule);

    panel.add(lblRefresh);
    panel.add(spnRefresh);
    panel.add(lblSeconds);
    panel.add(lblRules);
View Full Code Here


    previewTextField.setFont(font);
  }

  private void defineLayout() {
    Container container = getContentPane();
    SpringLayout layout = new SpringLayout();
    container.setLayout(layout);

    JLabel fontLabel = new JLabel(Translator.tr("Font family"));
    JLabel sizeLabel = new JLabel(Translator.tr("Font size"));
    JLabel previewLabel = new JLabel(Translator.tr("Preview"));

    container.add(fontLabel);
    container.add(fontFamilyCombo);
    container.add(sizeLabel);
    container.add(fontSizeCombo);
    container.add(previewLabel);
    container.add(previewTextField);

    previewTextField.setPreferredSize(new Dimension(300, 100));

    container.add(okButton);
    container.add(cancelButton);

    layout.putConstraint(SpringLayout.WEST, fontLabel, 5, SpringLayout.WEST,
        container);
    layout.putConstraint(SpringLayout.WEST, fontFamilyCombo, 5,
        SpringLayout.WEST, container);
    layout.putConstraint(SpringLayout.WEST, sizeLabel, 5, SpringLayout.WEST,
        container);
    layout.putConstraint(SpringLayout.WEST, fontSizeCombo, 5, SpringLayout.WEST,
        container);
    layout.putConstraint(SpringLayout.WEST, previewLabel, 5, SpringLayout.WEST,
        container);
    layout.putConstraint(SpringLayout.WEST, previewTextField, 5, SpringLayout.WEST,
        container);
    layout.putConstraint(SpringLayout.EAST, okButton, -5, SpringLayout.WEST,
        cancelButton);
    layout.putConstraint(SpringLayout.EAST, cancelButton, -5,
        SpringLayout.EAST, container);

    layout.putConstraint(SpringLayout.NORTH, fontLabel, 5, SpringLayout.NORTH,
        container);
    layout.putConstraint(SpringLayout.NORTH, fontFamilyCombo, 5,
        SpringLayout.SOUTH, fontLabel);
    layout.putConstraint(SpringLayout.NORTH, sizeLabel, 5, SpringLayout.SOUTH,
        fontFamilyCombo);
    layout.putConstraint(SpringLayout.NORTH, fontSizeCombo, 5, SpringLayout.SOUTH,
        sizeLabel);
    layout.putConstraint(SpringLayout.NORTH, previewLabel, 5, SOUTH, fontSizeCombo);
    layout.putConstraint(SpringLayout.NORTH, previewTextField, 5, SOUTH, previewLabel);
    layout.putConstraint(SpringLayout.NORTH, okButton, 15, SpringLayout.SOUTH,
        previewTextField);
    layout.putConstraint(SpringLayout.NORTH, cancelButton, 15,
        SpringLayout.SOUTH, previewTextField);

    Constraints containerCons = layout.getConstraints(container);
    Constraints fontCons = layout.getConstraints(previewTextField);
    Constraints okCons = layout.getConstraints(okButton);

    containerCons.setWidth(Spring.sum(Spring.constant(5),
        fontCons.getConstraint(EAST)));
    containerCons.setHeight(Spring.sum(Spring.constant(5),
        okCons.getConstraint(SOUTH)));
View Full Code Here

  }

  private void placeComponents() {
    JLabel lblTypes = new JLabel(Translator.tr("Log types"));

    SpringLayout layout = new SpringLayout();
    setLayout(layout);

    layout.putConstraint(NORTH, lblTypes, 5, NORTH, this);
    layout.putConstraint(NORTH, scrollTypes, 5, SOUTH, lblTypes);
    layout.putConstraint(NORTH, btnAdd, 5, SOUTH, scrollTypes);
    layout.putConstraint(NORTH, btnRename, 5, SOUTH, btnAdd);
    layout.putConstraint(NORTH, btnRemove, 5, SOUTH, btnRename);

    layout.putConstraint(WEST, lblTypes, 5, WEST, this);
    layout.putConstraint(WEST, scrollTypes, 5, WEST, this);
    layout.putConstraint(EAST, scrollTypes, -5, EAST, this);
    layout.putConstraint(WEST, btnAdd, 5, WEST, this);
    layout.putConstraint(EAST, btnAdd, -5, EAST, this);
    layout.putConstraint(WEST, btnRename, 5, WEST, this);
    layout.putConstraint(EAST, btnRename, -5, EAST, this);
    layout.putConstraint(WEST, btnRemove, 5, WEST, this);
    layout.putConstraint(EAST, btnRemove, -5, EAST, this);

    add(lblTypes);
    add(scrollTypes);
    add(btnAdd);
    add(btnRename);
View Full Code Here

    defineLayout();
  }

  private void defineLayout() {
    Container container = getContentPane();
    SpringLayout layout = new SpringLayout();
    container.setLayout(layout);

    JLabel _lookAndFeel = new JLabel(Translator.tr("Look and feel"));
    JLabel _language = new JLabel(Translator.tr("Language"));

    container.add(_lookAndFeel);
    container.add(lookAndFeelComboBox);

    if (languageComboBox.getModel().getSize() > 0) {
      container.add(_language);
      container.add(languageComboBox);
    }

    container.add(okButton);
    container.add(cancelButton);

    layout.putConstraint(SpringLayout.WEST, _lookAndFeel, 5,
        SpringLayout.WEST, container);
    layout.putConstraint(SpringLayout.WEST, lookAndFeelComboBox, 5,
        SpringLayout.WEST, container);
    layout.putConstraint(SpringLayout.WEST, _language, 5,
        SpringLayout.WEST, container);
    layout.putConstraint(SpringLayout.WEST, languageComboBox, 5,
        SpringLayout.WEST, container);
    layout.putConstraint(SpringLayout.EAST, okButton, -5, SpringLayout.WEST,
        cancelButton);
    layout.putConstraint(SpringLayout.EAST, cancelButton, -5,
        SpringLayout.EAST, container);

    layout.putConstraint(SpringLayout.NORTH, _lookAndFeel, 5,
        SpringLayout.NORTH, container);
    layout.putConstraint(SpringLayout.NORTH, lookAndFeelComboBox, 5,
        SpringLayout.SOUTH, _lookAndFeel);
    layout.putConstraint(SpringLayout.NORTH, _language, 5,
        SpringLayout.SOUTH, lookAndFeelComboBox);
    layout.putConstraint(SpringLayout.NORTH, languageComboBox, 5,
        SpringLayout.SOUTH, _language);
    layout.putConstraint(SpringLayout.NORTH, okButton, 15, SpringLayout.SOUTH,
        languageComboBox);
    layout.putConstraint(SpringLayout.NORTH, cancelButton, 15,
        SpringLayout.SOUTH, languageComboBox);

    Constraints containerCons = layout.getConstraints(container);
    Constraints okCons = layout.getConstraints(okButton);

    containerCons.setWidth(Spring.constant(270));
    containerCons.setHeight(Spring.sum(Spring.constant(5),
        okCons.getConstraint(SOUTH)));
View Full Code Here

        // ROTATION PANEL
        rotationPanel.setBorder(BorderFactory.createTitledBorder(GettextResource.gettext(
                config.getI18nResourceBundle(), "Rotation")));
        rotationPanel.setPreferredSize(new Dimension(200, 95));
        rotationPanel.setMinimumSize(new Dimension(160, 90));
        rotationPanelLayout = new SpringLayout();
        rotationPanel.setLayout(rotationPanelLayout);

        rotationBox = new JComboBox();
        rotationBox.addItem("90");
        rotationBox.addItem("180");
        rotationBox.addItem("270");
        rotationPagesBox = new JComboBox();
        rotationPagesBox.addItem(new StringItem(ValidationUtility.ALL_STRING, GettextResource.gettext(config
                .getI18nResourceBundle(), "All")));
        rotationPagesBox.addItem(new StringItem(ValidationUtility.EVEN_STRING, GettextResource.gettext(config
                .getI18nResourceBundle(), "Even")));
        rotationPagesBox.addItem(new StringItem(ValidationUtility.ODD_STRING, GettextResource.gettext(config
                .getI18nResourceBundle(), "Odd")));

        rotateComboLabel.setText(GettextResource.gettext(config.getI18nResourceBundle(),
                "Clockwise rotation (degrees):"));
        rotatePagesComboLabel.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Pages:"));

        StringBuffer sb1 = new StringBuffer();
        sb1.append("<html><body><b>" + GettextResource.gettext(config.getI18nResourceBundle(), "Rotation") + "</b>");
        sb1.append("<p> "
                + GettextResource.gettext(config.getI18nResourceBundle(), "Set the rotation degrees (clockwise).")
                + "</p>");
        sb1.append("<p> "
                + GettextResource.gettext(config.getI18nResourceBundle(), "Set the pages that will be rotated.")
                + "</p>");
        sb1.append("</body></html>");
        rotateHelpLabel = new JHelpLabel(sb1.toString(), true);

        rotationPanel.add(rotateHelpLabel);
        rotationPanel.add(rotateComboLabel);
        rotationPanel.add(rotationBox);
        rotationPanel.add(rotatePagesComboLabel);
        rotationPanel.add(rotationPagesBox);
        rotationPanel.add(rotateHelpLabel);

        topConst.fill = GridBagConstraints.HORIZONTAL;
        topConst.weightx = 0.0;
        topConst.weighty = 0.0;
        topConst.gridwidth = 3;
        topConst.gridheight = 1;
        topConst.gridx = 0;
        topConst.gridy = 1;
        topPanel.add(rotationPanel, topConst);

        // DESTINATION_PANEL
        destinationPanelLayout = new SpringLayout();
        destinationPanel.setLayout(destinationPanelLayout);
        TitledBorder titledBorder = BorderFactory.createTitledBorder(GettextResource.gettext(config
                .getI18nResourceBundle(), "Destination folder"));
        destinationPanel.setBorder(titledBorder);
        destinationPanel.setPreferredSize(new Dimension(200, 160));
        destinationPanel.setMinimumSize(new Dimension(160, 150));

        // END_DESTINATION_PANEL

        destinationPanel.add(destinationTextField);
        topConst.fill = GridBagConstraints.HORIZONTAL;
        topConst.weightx = 0.0;
        topConst.weighty = 0.0;
        topConst.gridwidth = 3;
        topConst.gridheight = 1;
        topConst.gridx = 0;
        topConst.gridy = 2;
        topPanel.add(destinationPanel, topConst);

        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.BOTH;
        c.ipady = 5;
        c.weightx = 1.0;
        c.weighty = 1.0;
        c.gridwidth = 3;
        c.gridx = 0;
        c.gridy = 0;
        add(topPanel, c);
        // BROWSE_BUTTON
        browseButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JFileChooser fileChooser = SharedJFileChooser.getInstance(SharedJFileChooserType.NO_FILTER,
                        JFileChooser.DIRECTORIES_ONLY, destinationTextField.getText());
                if (fileChooser.showOpenDialog(browseButton.getParent()) == JFileChooser.APPROVE_OPTION) {
                    File chosenFile = fileChooser.getSelectedFile();
                    if (chosenFile != null) {
                        destinationTextField.setText(chosenFile.getAbsolutePath());
                    }

                }
            }
        });
        destinationPanel.add(browseButton);
        // END_BROWSE_BUTTON

        overwriteCheckbox.setSelected(true);
        destinationPanel.add(overwriteCheckbox);

        outputCompressedCheck.addItemListener(new CompressCheckBoxItemListener(versionCombo));
        outputCompressedCheck.setSelected(true);

        destinationPanel.add(outputCompressedCheck);
        destinationPanel.add(versionCombo);
        destinationPanel.add(outputVersionLabel);

        // HELP_LABEL_DESTINATION
        String helpTextDest = "<html><body><b>"
                + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                        "Destination output directory")
                + "</b>"
                + "<p>"
                + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                        "To choose a folder browse or enter the full path to the destination output directory.")
                + "</p>"
                + "<p>"
                + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                        "Check the box if you want to overwrite the output files if they already exist.")
                + "</p>"
                + "<p>"
                + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                        "Check the box if you want compressed output files.")
                + " "
                + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                        "PDF version 1.5 or above.")
                + "</p>"
                + "<p>"
                + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                        "Set the pdf version of the ouput document.") + "</p>" + "</body></html>";
        destinationHelpLabel = new JHelpLabel(helpTextDest, true);
        destinationPanel.add(destinationHelpLabel);
        // END_HELP_LABEL_DESTINATION
        outputOptionsPanel.setBorder(BorderFactory.createTitledBorder(GettextResource.gettext(config
                .getI18nResourceBundle(), "Output options")));
        outputOptionsPanel.setPreferredSize(new Dimension(200, 55));
        outputOptionsPanel.setMinimumSize(new Dimension(160, 50));
        outputOptionsPanelLayout = new SpringLayout();
        outputOptionsPanel.setLayout(outputOptionsPanelLayout);

        outPrefixLabel.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Output file names prefix:"));
        outputOptionsPanel.add(outPrefixLabel);
View Full Code Here

    final Caption labelInputDir = new Caption("Input Directory: ");
    final Caption labelStyleMapFile = new Caption("TypeSystem or AE Descriptor File: ");

    JPanel controlPanel = new JPanel();
    controlPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    controlPanel.setLayout(new SpringLayout());

    // Once we add components to controlPanel, we'll
    // call SpringUtilities::makeCompactGrid on it.

    // controlPanel.setLayout(new GridLayout(4, 2, 8, 4));
View Full Code Here

    JPanel southernPanel = new JPanel();
    southernPanel.setLayout(new BoxLayout(southernPanel, BoxLayout.Y_AXIS));

    JPanel controlsPanel = new JPanel();
    controlsPanel.setLayout(new SpringLayout());

    Caption displayFormatLabel = new Caption("Results Display Format:");
    controlsPanel.add(displayFormatLabel);

    JPanel displayFormatPanel = new JPanel();
View Full Code Here

    labelEncoding = new Caption("Character Encoding: ");

    JPanel controlPanel = new JPanel();
    controlPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    controlPanel.setLayout(new SpringLayout());

    // Once we add components to controlPanel, we'll
    // call SpringUtilities::makeCompactGrid on it.

    // controlPanel.setLayout(new GridLayout(4, 2, 8, 4));
View Full Code Here

   * @param yPad
   *          y padding between cells
   */
  public static void makeGrid(Container parent, int rows, int cols, int initialX, int initialY,
          int xPad, int yPad) {
    SpringLayout layout;
    try {
      layout = (SpringLayout) parent.getLayout();
    } catch (ClassCastException exc) {
      System.err.println("The first argument to makeGrid must use SpringLayout.");
      return;
    }

    Spring xPadSpring = Spring.constant(xPad);
    Spring yPadSpring = Spring.constant(yPad);
    Spring initialXSpring = Spring.constant(initialX);
    Spring initialYSpring = Spring.constant(initialY);
    int max = rows * cols;

    // Calculate Springs that are the max of the width/height so that all
    // cells have the same size.
    Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
    Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
    for (int i = 1; i < max; i++) {
      SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));

      maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
      maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
    }

    // Apply the new width/height Spring. This forces all the
    // components to have the same size.
    for (int i = 0; i < max; i++) {
      SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));

      cons.setWidth(maxWidthSpring);
      cons.setHeight(maxHeightSpring);
    }

    // Then adjust the x/y constraints of all the cells so that they
    // are aligned in a grid.
    SpringLayout.Constraints lastCons = null;
    SpringLayout.Constraints lastRowCons = null;
    for (int i = 0; i < max; i++) {
      SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));
      if (i % cols == 0) { // start of new row
        lastRowCons = lastCons;
        cons.setX(initialXSpring);
      } else { // x position depends on previous component
        cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST), xPadSpring));
      }

      if (i / cols == 0) { // first row
        cons.setY(initialYSpring);
      } else { // y position depends on previous row
        cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH), yPadSpring));
      }
      lastCons = cons;
    }

    // Set the parent's size.
    SpringLayout.Constraints pCons = layout.getConstraints(parent);
    pCons.setConstraint(SpringLayout.SOUTH, Spring.sum(Spring.constant(yPad), lastCons
            .getConstraint(SpringLayout.SOUTH)));
    pCons.setConstraint(SpringLayout.EAST, Spring.sum(Spring.constant(xPad), lastCons
            .getConstraint(SpringLayout.EAST)));
  }
View Full Code Here

  }

  /* Used by makeCompactGrid. */
  private static SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent,
          int cols) {
    SpringLayout layout = (SpringLayout) parent.getLayout();
    Component c = parent.getComponent(row * cols + col);
    return layout.getConstraints(c);
  }
View Full Code Here

TOP

Related Classes of javax.swing.SpringLayout$SpringProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.