Package javax.swing

Examples of javax.swing.SpringLayout$ProxySpring


     * @param yPad
     *            y padding between cells
     */
    public static void makeCompactGrid(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 makeCompactGrid must use SpringLayout.");
            return;
        }

        // Align all cells in each column and make them the same width.
        Spring x = Spring.constant(initialX);
        for (int c = 0; c < cols; c++) {
            Spring width = Spring.constant(0);
            for (int r = 0; r < rows; r++) {
                width = Spring.max(width, getConstraintsForCell(r, c, parent,
                        cols).getWidth());
            }
            for (int r = 0; r < rows; r++) {
                SpringLayout.Constraints constraints = getConstraintsForCell(r,
                        c, parent, cols);
                constraints.setX(x);
                constraints.setWidth(width);
            }
            x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
        }

        // Align all cells in each row and make them the same height.
        Spring y = Spring.constant(initialY);
        for (int r = 0; r < rows; r++) {
            Spring height = Spring.constant(0);
            for (int c = 0; c < cols; c++) {
                height = Spring.max(height, getConstraintsForCell(r, c, parent,
                        cols).getHeight());
            }
            for (int c = 0; c < cols; c++) {
                SpringLayout.Constraints constraints = getConstraintsForCell(r,
                        c, parent, cols);
                constraints.setY(y);
                constraints.setHeight(height);
            }
            y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
        }

        // Set the parent's size.
        SpringLayout.Constraints pCons = layout.getConstraints(parent);
        pCons.setConstraint(SpringLayout.SOUTH, y);
        pCons.setConstraint(SpringLayout.EAST, x);
    }
View Full Code Here


    private void initialize() {    
      config = Configuration.getInstance();
        setPanelIcon("/images/settings.png");
        setPreferredSize(new Dimension(400,480));

        settingsLayout = new SpringLayout();
        setLayout(settingsLayout);
   
    settingsOptionsPanel.setBorder(BorderFactory.createTitledBorder(GettextResource.gettext(config.getI18nResourceBundle(),"Settings")));
        grayBorderSettingsLayout = new SpringLayout();
        settingsOptionsPanel.setLayout(grayBorderSettingsLayout);
        add(settingsOptionsPanel);
   
        gridOptionsPanel.setLayout(new GridLayout(5,4,3,3));
View Full Code Here

    manager = newManager;

    fsp = new FolderSelectorPane();
    fsp.configureEditor(propertyName + ".targetFolder", manager);

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

    this.add(fsp.getLabelComponent());
    this.add(fsp.getValueComponent());

    layout.putConstraint(SpringLayout.NORTH, fsp.getLabelComponent(), 0, SpringLayout.NORTH, this);
    layout.putConstraint(SpringLayout.WEST, fsp.getLabelComponent(), 0, SpringLayout.WEST, this);
    layout.putConstraint(SpringLayout.SOUTH, this, 0, SpringLayout.SOUTH, fsp.getLabelComponent());
    layout.putConstraint(SpringLayout.WEST, fsp.getValueComponent(), 5, SpringLayout.EAST, fsp.getLabelComponent());
    layout.putConstraint(SpringLayout.EAST, this, 5, SpringLayout.EAST, fsp.getValueComponent());

    this.setPreferredSize(new java.awt.Dimension(150, fsp.getLabelComponent().getMinimumSize().height));
    this.setMaximumSize(new java.awt.Dimension(Integer.MAX_VALUE, fsp.getLabelComponent().getMinimumSize().height));

  }
View Full Code Here

  protected void doInit()
    {
        Dimension dim;
        JPanel ctrlPanel = new JPanel();
        SpringLayout layout = new SpringLayout();
        ctrlPanel.setLayout(layout);
        JLabel label = new JLabel(Main.getString("batchdialog_src_folder"));
        ctrlPanel.add(label);
        layout.putConstraint(SpringLayout.WEST, label, 10, SpringLayout.WEST, ctrlPanel);
        layout.putConstraint(SpringLayout.NORTH, label, 10, SpringLayout.NORTH, ctrlPanel);

        m_ctrl_srcFolder = new JTextField(m_batchData.m_srcFolder, 40);
        ctrlPanel.add(m_ctrl_srcFolder);
        layout.putConstraint(SpringLayout.WEST, m_ctrl_srcFolder, 0, SpringLayout.WEST, label);
        layout.putConstraint(SpringLayout.NORTH, m_ctrl_srcFolder, 5, SpringLayout.SOUTH, label);

        JButton button = new JButton(Main.getString("browse"));
        ctrlPanel.add(button);
        layout.putConstraint(SpringLayout.WEST, button, 10, SpringLayout.EAST, m_ctrl_srcFolder);
        layout.putConstraint(SpringLayout.VERTICAL_CENTER, button, 0, SpringLayout.VERTICAL_CENTER, m_ctrl_srcFolder);
        button.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent ev)
            {
                JFileChooser fileChooser = new JFileChooser(m_ctrl_srcFolder.getText());
                fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                fileChooser.setDialogTitle(Main.getString("batchdialog_browse_caption_src_folder"));
                if (fileChooser.showOpenDialog(m_mainFrame) == JFileChooser.APPROVE_OPTION)
                    m_ctrl_srcFolder.setText(m_batchData.m_srcFolder = fileChooser.getSelectedFile().getPath());
            }
        });
        layout.putConstraint(SpringLayout.EAST, ctrlPanel, 10, SpringLayout.EAST, button);

        m_ctrl_recursive = new JCheckBox(Main.getString("batchdialog_recursive"), m_batchData.m_bRecursive);
        ctrlPanel.add(m_ctrl_recursive);
        layout.putConstraint(SpringLayout.WEST, m_ctrl_recursive, 0, SpringLayout.WEST, m_ctrl_srcFolder);
        layout.putConstraint(SpringLayout.NORTH, m_ctrl_recursive, 15, SpringLayout.SOUTH, m_ctrl_srcFolder);

        m_ctrl_bmp = new JCheckBox(Main.getString("batchdialog_bmp"));
        ctrlPanel.add(m_ctrl_bmp);
        if ((m_batchData.m_srcTypes & JBatchData.BMP_FORMAT) != 0)
            m_ctrl_bmp.setSelected(true);
        layout.putConstraint(SpringLayout.EAST, m_ctrl_bmp, 0, SpringLayout.EAST, m_ctrl_srcFolder);
        layout.putConstraint(SpringLayout.NORTH, m_ctrl_bmp, 0, SpringLayout.NORTH, m_ctrl_recursive);
       
        m_ctrl_png = new JCheckBox(Main.getString("batchdialog_png"));
        ctrlPanel.add(m_ctrl_png);
        if ((m_batchData.m_srcTypes & JBatchData.PNG_FORMAT) != 0)
            m_ctrl_png.setSelected(true);
        layout.putConstraint(SpringLayout.EAST, m_ctrl_png, -10, SpringLayout.WEST, m_ctrl_bmp);
        layout.putConstraint(SpringLayout.NORTH, m_ctrl_png, 0, SpringLayout.NORTH, m_ctrl_recursive);

        m_ctrl_jpg = new JCheckBox(Main.getString("batchdialog_jpg"));
        ctrlPanel.add(m_ctrl_jpg);
        if ((m_batchData.m_srcTypes & JBatchData.JPG_FORMAT) != 0)
            m_ctrl_jpg.setSelected(true);
        layout.putConstraint(SpringLayout.EAST, m_ctrl_jpg, -10, SpringLayout.WEST, m_ctrl_png);
        layout.putConstraint(SpringLayout.NORTH, m_ctrl_jpg, 0, SpringLayout.NORTH, m_ctrl_recursive);

        JSeparator sep = new JSeparator(JSeparator.HORIZONTAL);
        ctrlPanel.add(sep);
        layout.putConstraint(SpringLayout.WEST, sep, 10, SpringLayout.WEST, ctrlPanel);
        layout.putConstraint(SpringLayout.EAST, sep, -10, SpringLayout.EAST, button);
        layout.putConstraint(SpringLayout.NORTH, sep, 30, SpringLayout.SOUTH, m_ctrl_recursive);

        /* Target stuff */

        label = new JLabel(Main.getString("batchdialog_target_folder"));
        ctrlPanel.add(label);
        layout.putConstraint(SpringLayout.WEST, label, 0, SpringLayout.WEST, m_ctrl_srcFolder);
        layout.putConstraint(SpringLayout.NORTH, label, 30, SpringLayout.SOUTH, sep);

        m_ctrl_targetFolder = new JTextField(m_batchData.m_targetFolder != null && !m_batchData.m_targetFolder.isEmpty() ? m_batchData.m_targetFolder : m_batchData.m_srcFolder, 40);
        ctrlPanel.add(m_ctrl_targetFolder);
        layout.putConstraint(SpringLayout.WEST, m_ctrl_targetFolder, 0, SpringLayout.WEST, label);
        layout.putConstraint(SpringLayout.EAST, m_ctrl_targetFolder, 0, SpringLayout.EAST, m_ctrl_srcFolder);
        layout.putConstraint(SpringLayout.NORTH, m_ctrl_targetFolder, 5, SpringLayout.SOUTH, label);

        JButton button_target_browse = new JButton(Main.getString("browse"));
        ctrlPanel.add(button_target_browse);
        layout.putConstraint(SpringLayout.VERTICAL_CENTER, button_target_browse, 0, SpringLayout.VERTICAL_CENTER, m_ctrl_targetFolder);
        layout.putConstraint(SpringLayout.WEST, button_target_browse, 10, SpringLayout.EAST, m_ctrl_targetFolder);
        layout.putConstraint(SpringLayout.EAST, button_target_browse, 0, SpringLayout.EAST, button);
        button_target_browse.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent ev)
            {
                JFileChooser fileChooser = new JFileChooser(m_ctrl_targetFolder.getText());
                fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                fileChooser.setDialogTitle(Main.getString("batchdialog_browse_caption_target_folder"));
                if (fileChooser.showOpenDialog(m_mainFrame) == JFileChooser.APPROVE_OPTION)
                    m_ctrl_targetFolder.setText(m_batchData.m_targetFolder = fileChooser.getSelectedFile().getPath());
            }
        });
        label = new JLabel(Main.getString("batchdialog_target_template"));
        ctrlPanel.add(label);
        layout.putConstraint(SpringLayout.WEST, label, 0, SpringLayout.WEST, m_ctrl_targetFolder);
        layout.putConstraint(SpringLayout.NORTH, label, 15, SpringLayout.SOUTH, m_ctrl_targetFolder);

        m_ctrl_targetTemplate = new JTextField(m_batchData.m_targetTemplate, 40);
        ctrlPanel.add(m_ctrl_targetTemplate);
        layout.putConstraint(SpringLayout.WEST, m_ctrl_targetTemplate, 0, SpringLayout.WEST, label);
        layout.putConstraint(SpringLayout.EAST, m_ctrl_targetTemplate, 0, SpringLayout.EAST, m_ctrl_targetFolder);
        layout.putConstraint(SpringLayout.NORTH, m_ctrl_targetTemplate, 5, SpringLayout.SOUTH, label);

        label = new JLabel(Main.getString("batchdialog_target_format"));
        ctrlPanel.add(label);
        layout.putConstraint(SpringLayout.WEST, label, 0, SpringLayout.WEST, m_ctrl_targetTemplate);
        layout.putConstraint(SpringLayout.NORTH, label, 20, SpringLayout.SOUTH, m_ctrl_targetTemplate);

        m_ctrl_targetFormat = new JComboBox();
        m_ctrl_targetFormat.addItem(Main.getString("batchdialog_select_jpg"));
        m_ctrl_targetFormat.addItem(Main.getString("batchdialog_select_png"));
        m_ctrl_targetFormat.addItem(Main.getString("batchdialog_select_bmp"));
        ctrlPanel.add(m_ctrl_targetFormat);
        layout.putConstraint(SpringLayout.WEST, m_ctrl_targetFormat, 0, SpringLayout.WEST, label);
        layout.putConstraint(SpringLayout.NORTH, m_ctrl_targetFormat, 5, SpringLayout.SOUTH, label);

        final JLabel label_quality = new JLabel(Main.getString("batchdialog_target_quality"));
        ctrlPanel.add(label_quality);
        layout.putConstraint(SpringLayout.WEST, label_quality, 50, SpringLayout.EAST, m_ctrl_targetFormat);
        layout.putConstraint(SpringLayout.NORTH, label_quality, 0, SpringLayout.NORTH, label);
       
        m_ctrl_targetQuality = new JComboBox();
        ctrlPanel.add(m_ctrl_targetQuality);
        m_ctrl_targetQuality.setEditable(true);
        for (double i=0; i<=1.01; i+=.05)
            m_ctrl_targetQuality.addItem(String.format("%.2f", i));
        m_ctrl_targetQuality.setSelectedItem(String.format("%.2f", m_batchData.m_quality));
        layout.putConstraint(SpringLayout.WEST, m_ctrl_targetQuality, 0, SpringLayout.WEST, label_quality);
        layout.putConstraint(SpringLayout.NORTH, m_ctrl_targetQuality, 5, SpringLayout.SOUTH, label_quality);

        m_ctrl_optimizedHuffman = new JCheckBox(Main.getString("batchdialog_target_optimizedhuffman"), m_batchData.m_bOptimizedHuffmanTable);
        ctrlPanel.add(m_ctrl_optimizedHuffman);
        layout.putConstraint(SpringLayout.WEST, m_ctrl_optimizedHuffman, 0, SpringLayout.WEST, label_quality);
        layout.putConstraint(SpringLayout.NORTH, m_ctrl_optimizedHuffman, 10, SpringLayout.SOUTH, m_ctrl_targetQuality);

        final JLabel label_scale = new JLabel(Main.getString("batchdialog_target_scale"));
        ctrlPanel.add(label_scale);
        layout.putConstraint(SpringLayout.WEST, label_scale, 50, SpringLayout.EAST, m_ctrl_targetQuality);
        layout.putConstraint(SpringLayout.NORTH, label_scale, 0, SpringLayout.NORTH, label_quality);

    m_ctrl_scale = new JComboBox();
        ctrlPanel.add(m_ctrl_scale);
        layout.putConstraint(SpringLayout.WEST, m_ctrl_scale, 0, SpringLayout.WEST, label_scale);
        layout.putConstraint(SpringLayout.NORTH, m_ctrl_scale, 5, SpringLayout.SOUTH, label_scale);
        m_ctrl_scale.setEditable(true);
        double[] scales = {1.0/8.0, 1.0/4.0, 1.0/3.0, 1.0/2.0, 2.0/3.0, 3.0/4.0, 7.0/8.0, 1.0, 5.0/4.0, 4.0/3.0, 3.0/2.0, 5.0/3.0, 7.0/4.0, 8.0/4.0};
        for (double scale : scales)
            m_ctrl_scale.addItem(String.format("%.3f", scale));
        m_ctrl_scale.setSelectedItem(String.format("%.3f", m_batchData.m_scaleFactor));
View Full Code Here

  protected void doInit()
  {
        setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        Container contentPane = getContentPane();
        SpringLayout layout = new SpringLayout();
        contentPane.setLayout(layout);

        m_label = new JAALabel(m_labelText);
        contentPane.add(m_label);
        layout.putConstraint(SpringLayout.WEST, m_label, 10, SpringLayout.WEST, contentPane);
        layout.putConstraint(SpringLayout.NORTH, m_label, 10, SpringLayout.NORTH, contentPane);

        m_bar = new JProgBar(m_min, m_max);
        m_bar.setIndeterminate(m_bIndeterminate);
        contentPane.add(m_bar);
        layout.putConstraint(SpringLayout.WEST, m_bar, 0, SpringLayout.WEST, m_label);
        layout.putConstraint(SpringLayout.SOUTH, m_bar, 30, SpringLayout.NORTH, m_bar);
        layout.putConstraint(SpringLayout.EAST, m_bar, -10, SpringLayout.EAST, contentPane);
        layout.putConstraint(SpringLayout.NORTH, m_bar, 5, SpringLayout.SOUTH, m_label);

        if (m_cancelStr != null)
        {
            JButton cancel = new JButton(m_cancelStr);
            contentPane.add(cancel);
            layout.putConstraint(SpringLayout.HORIZONTAL_CENTER, cancel, 0, SpringLayout.HORIZONTAL_CENTER, contentPane);
            layout.putConstraint(SpringLayout.SOUTH, cancel, -10, SpringLayout.SOUTH, contentPane);
            //layout.putConstraint(SpringLayout.SOUTH, m_bar, -20, SpringLayout.NORTH, cancel);
            cancel.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent ev)
                {
View Full Code Here

   
    private final JCheckBox distributedCheckbox;
   
    EvolutionPanel() {
      super(new FlowLayout(FlowLayout.LEFT, 0, 0));
      JPanel innerPanel = new JPanel(new SpringLayout());
     
      populationLabel = new JLabel("Population Size: ");
      populationSpinner = new JSpinner(new SpinnerNumberModel(300, 2, 10000, 1));
      populationLabel.setLabelFor(populationSpinner);
      innerPanel.add(populationLabel);
View Full Code Here

      }
    });
    frame.setLocationRelativeTo(null);
    frame.setSize(551, 427);
    frame.add(panelTop);
    SpringLayout sl_panelTop = new SpringLayout();
    panelTop.setLayout(sl_panelTop);
   
    JLabel lblUsr = new JLabel("用户id");
    sl_panelTop.putConstraint(SpringLayout.NORTH, lblUsr, 10, SpringLayout.NORTH, panelTop);
    lblUsr.setFont(new Font("宋体", Font.PLAIN, 14));
    panelTop.add(lblUsr);
   
    JLabel lblPwd = new JLabel("密码");
    sl_panelTop.putConstraint(SpringLayout.WEST, lblPwd, 10, SpringLayout.WEST, panelTop);
    lblPwd.setFont(new Font("宋体", Font.PLAIN, 14));
    panelTop.add(lblPwd);
   
    JLabel lblFileNmae = new JLabel("存储路径");
    sl_panelTop.putConstraint(SpringLayout.NORTH, lblFileNmae, 54, SpringLayout.NORTH, panelTop);
    sl_panelTop.putConstraint(SpringLayout.SOUTH, lblPwd, -6, SpringLayout.NORTH, lblFileNmae);
    sl_panelTop.putConstraint(SpringLayout.WEST, lblFileNmae, 10, SpringLayout.WEST, panelTop);
    lblFileNmae.setFont(new Font("宋体", Font.PLAIN, 14));
    panelTop.add(lblFileNmae);
   
    JLabel lblFileType = new JLabel("文件格式");
    sl_panelTop.putConstraint(SpringLayout.NORTH, lblFileType, 83, SpringLayout.NORTH, panelTop);
    sl_panelTop.putConstraint(SpringLayout.WEST, lblFileType, 10, SpringLayout.WEST, panelTop);
    lblFileType.setFont(new Font("宋体", Font.PLAIN, 14));
    panelTop.add(lblFileType);
   
    txtUsr = new JTextField();
    sl_panelTop.putConstraint(SpringLayout.EAST, lblUsr, -28, SpringLayout.WEST, txtUsr);
    sl_panelTop.putConstraint(SpringLayout.NORTH, txtUsr, 7, SpringLayout.NORTH, panelTop);
    sl_panelTop.putConstraint(SpringLayout.WEST, txtUsr, 80, SpringLayout.WEST, panelTop);
    sl_panelTop.putConstraint(SpringLayout.EAST, txtUsr, -10, SpringLayout.EAST, panelTop);
    panelTop.add(txtUsr);
    txtUsr.setColumns(10);
   
    txtPwd = new JTextField();
    sl_panelTop.putConstraint(SpringLayout.EAST, txtPwd, 0, SpringLayout.EAST, txtUsr);
    sl_panelTop.putConstraint(SpringLayout.SOUTH, txtUsr, -1, SpringLayout.NORTH, txtPwd);
    sl_panelTop.putConstraint(SpringLayout.NORTH, txtPwd, -2, SpringLayout.NORTH, lblPwd);
    sl_panelTop.putConstraint(SpringLayout.WEST, txtPwd, 42, SpringLayout.EAST, lblPwd);
    panelTop.add(txtPwd);
    txtPwd.setColumns(10);
   
    txtFilePath = new JTextField();
    sl_panelTop.putConstraint(SpringLayout.NORTH, txtFilePath, 3, SpringLayout.SOUTH, txtPwd);
    sl_panelTop.putConstraint(SpringLayout.WEST, txtFilePath, 0, SpringLayout.WEST, txtUsr);
    panelTop.add(txtFilePath);
    txtFilePath.setColumns(10);
   
    String dir = System.getProperty("user.dir");
    txtFilePath.setText(dir);
   
    rdbtnCSV = new JRadioButton(".csv");
    sl_panelTop.putConstraint(SpringLayout.SOUTH, rdbtnCSV, -295, SpringLayout.SOUTH, panelTop);
    rdbtnCSV.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0)
      {
        onRadioButtonClick(1);
      }
    });
   
    JButton btnBrowse = new JButton("浏览");
    btnBrowse.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        JFileChooser chooser = new JFileChooser(txtFilePath.getText());
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int r = chooser.showOpenDialog(null);
        if(r == JFileChooser.APPROVE_OPTION)
        {
          File f = chooser.getSelectedFile();
          txtFilePath.setText(f.getPath());
        }
      }
    });
    sl_panelTop.putConstraint(SpringLayout.EAST, txtFilePath, -6, SpringLayout.WEST, btnBrowse);
    sl_panelTop.putConstraint(SpringLayout.NORTH, btnBrowse, -2, SpringLayout.NORTH, lblFileNmae);
    sl_panelTop.putConstraint(SpringLayout.EAST, btnBrowse, 0, SpringLayout.EAST, txtUsr);
    panelTop.add(btnBrowse);
    sl_panelTop.putConstraint(SpringLayout.WEST, rdbtnCSV, 14, SpringLayout.EAST, lblFileType);
    rdbtnCSV.setFont(new Font("宋体", Font.PLAIN, 14));
    panelTop.add(rdbtnCSV);
   
    rdbtnXML = new JRadioButton(".xml");
    rdbtnXML.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        onRadioButtonClick(2);
      }
    });
    sl_panelTop.putConstraint(SpringLayout.NORTH, rdbtnXML, -4, SpringLayout.NORTH, lblFileType);
    sl_panelTop.putConstraint(SpringLayout.WEST, rdbtnXML, 6, SpringLayout.EAST, rdbtnCSV);
    rdbtnXML.setFont(new Font("宋体", Font.PLAIN, 14));
    panelTop.add(rdbtnXML);
   
    rdbtnHTML = new JRadioButton(".html");
    rdbtnHTML.setSelected(true);
    rdbtnHTML.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0)
      {
        onRadioButtonClick(3);
      }
    });
    sl_panelTop.putConstraint(SpringLayout.NORTH, rdbtnHTML, -3, SpringLayout.NORTH, lblFileType);
    sl_panelTop.putConstraint(SpringLayout.WEST, rdbtnHTML, 6, SpringLayout.EAST, rdbtnXML);
    rdbtnHTML.setFont(new Font("宋体", Font.PLAIN, 14));
    panelTop.add(rdbtnHTML);
   
    rdbtnTXT = new JRadioButton(".txt");
    rdbtnTXT.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0)
      {
        onRadioButtonClick(4);
      }
    });
    sl_panelTop.putConstraint(SpringLayout.NORTH, rdbtnTXT, -3, SpringLayout.NORTH, lblFileType);
    sl_panelTop.putConstraint(SpringLayout.WEST, rdbtnTXT, 6, SpringLayout.EAST, rdbtnHTML);
    rdbtnTXT.setFont(new Font("宋体", Font.PLAIN, 14));
    panelTop.add(rdbtnTXT);
   
    buttongroup = new ButtonGroup();
    buttongroup.add(rdbtnCSV);
    buttongroup.add(rdbtnXML);
    buttongroup.add(rdbtnHTML);
    buttongroup.add(rdbtnTXT);

    btnStart = new JButton("开始");
    sl_panelTop.putConstraint(SpringLayout.WEST, btnStart, 0, SpringLayout.WEST, lblUsr);
    btnStart.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        onStartButtonClick();
      }
    });
    panelTop.add(btnStart);
   
    txtLog = new JTextArea();
    txtLog.setText("饭否消息导出工具 v2.4.0\r\n发布日期:2012年10月7日\r\n作者:@烽麒\r\n网站:http://fq.vc\r\n");
    txtLog.setEditable(false);
    JScrollPane scroll = new JScrollPane(txtLog);
    sl_panelTop.putConstraint(SpringLayout.SOUTH, btnStart, -6, SpringLayout.NORTH, scroll);
    sl_panelTop.putConstraint(SpringLayout.NORTH, scroll, 166, SpringLayout.NORTH, panelTop);
    sl_panelTop.putConstraint(SpringLayout.SOUTH, scroll, -10, SpringLayout.SOUTH, panelTop);
    sl_panelTop.putConstraint(SpringLayout.WEST, scroll, 0, SpringLayout.WEST, lblUsr);
    sl_panelTop.putConstraint(SpringLayout.EAST, scroll, 0, SpringLayout.EAST, txtUsr);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    panelTop.add(scroll);
   
    chkbxPic = new JCheckBox("导出图片");
    sl_panelTop.putConstraint(SpringLayout.NORTH, chkbxPic, -4, SpringLayout.NORTH, lblFileType);
    sl_panelTop.putConstraint(SpringLayout.WEST, chkbxPic, 6, SpringLayout.EAST, rdbtnTXT);
    chkbxPic.setSelected(true);
    chkbxPic.setEnabled(false);
    chkbxPic.setFont(new Font("宋体", Font.PLAIN, 14));
    panelTop.add(chkbxPic);
   
    JLabel lblExpType = new JLabel("导出内容");
    sl_panelTop.putConstraint(SpringLayout.NORTH, lblExpType, 108, SpringLayout.NORTH, panelTop);
    sl_panelTop.putConstraint(SpringLayout.EAST, lblExpType, 0, SpringLayout.EAST, lblFileType);
    lblExpType.setFont(new Font("宋体", Font.PLAIN, 14));
    panelTop.add(lblExpType);
   
    rdbtnUsrTL = new JRadioButton("已发消息");
    rdbtnUsrTL.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        onRadioButton2Click(1);
      }
    });
    rdbtnUsrTL.setSelected(true);
    sl_panelTop.putConstraint(SpringLayout.NORTH, rdbtnUsrTL, 105, SpringLayout.NORTH, panelTop);
    sl_panelTop.putConstraint(SpringLayout.WEST, rdbtnUsrTL, 0, SpringLayout.WEST, txtUsr);
    rdbtnUsrTL.setFont(new Font("宋体", Font.PLAIN, 12));
    panelTop.add(rdbtnUsrTL);
   
    rdbtnMention = new JRadioButton("@提到我的消息");
    sl_panelTop.putConstraint(SpringLayout.NORTH, rdbtnMention, 0, SpringLayout.SOUTH, rdbtnHTML);
    sl_panelTop.putConstraint(SpringLayout.WEST, rdbtnMention, 0, SpringLayout.EAST, rdbtnUsrTL);
    rdbtnMention.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        onRadioButton2Click(2);
      }
    });
    rdbtnMention.setFont(new Font("宋体", Font.PLAIN, 12));
    panelTop.add(rdbtnMention);
   
    rdbtnDM = new JRadioButton("私信");
    sl_panelTop.putConstraint(SpringLayout.NORTH, rdbtnDM, 0, SpringLayout.SOUTH, rdbtnHTML);
    sl_panelTop.putConstraint(SpringLayout.WEST, rdbtnDM, 102, SpringLayout.EAST, rdbtnUsrTL);
    rdbtnDM.setEnabled(false);
    rdbtnDM.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        onRadioButton2Click(3);
      }
    });
    rdbtnDM.setFont(new Font("宋体", Font.PLAIN, 12));
    panelTop.add(rdbtnDM);
   
    rdbtnFav = new JRadioButton("收藏");
    rdbtnFav.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0)
      {
        onRadioButton2Click(5);
      }
    });
    sl_panelTop.putConstraint(SpringLayout.NORTH, rdbtnFav, -3, SpringLayout.NORTH, lblExpType);
    sl_panelTop.putConstraint(SpringLayout.WEST, rdbtnFav, 0, SpringLayout.EAST, rdbtnDM);
    rdbtnFav.setFont(new Font("宋体", Font.PLAIN, 12));
    panelTop.add(rdbtnFav);
   
    rdbtnFriTL = new JRadioButton("指定好友已发消息");
    sl_panelTop.putConstraint(SpringLayout.NORTH, rdbtnFriTL, -3, SpringLayout.NORTH, lblExpType);
    sl_panelTop.putConstraint(SpringLayout.WEST, rdbtnFriTL, 0, SpringLayout.EAST, rdbtnFav);
    rdbtnFriTL.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        onRadioButton2Click(4);
      }
    });
    rdbtnFriTL.setFont(new Font("宋体", Font.PLAIN, 12));
    panelTop.add(rdbtnFriTL);
   
    buttongroup2 = new ButtonGroup();
    buttongroup2.add(rdbtnUsrTL);
    buttongroup2.add(rdbtnMention);
    buttongroup2.add(rdbtnDM);
    buttongroup2.add(rdbtnFriTL);
    buttongroup2.add(rdbtnFav);
   
    txtFriID = new JTextField();
    sl_panelTop.putConstraint(SpringLayout.NORTH, txtFriID, -2, SpringLayout.NORTH, lblExpType);
    sl_panelTop.putConstraint(SpringLayout.WEST, txtFriID, 121, SpringLayout.EAST, rdbtnFav);
    sl_panelTop.putConstraint(SpringLayout.EAST, txtFriID, 0, SpringLayout.EAST, txtUsr);
    txtFriID.setEnabled(false);
    txtFriID.setText("好友ID");
    txtFriID.setToolTipText("好友ID");
    panelTop.add(txtFriID);
    txtFriID.setColumns(10);
View Full Code Here

    {
        if (!(parent.getLayout() instanceof SpringLayout))
        {
            throw new IllegalArgumentException("The first argument to makeGrid must use SpringLayout.");
        }
        SpringLayout layout = (SpringLayout) parent.getLayout();

        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 lastConstraints = null;
        SpringLayout.Constraints lastRowConstraints = null;
        for (int i = 0; i < max; i++)
        {
            SpringLayout.Constraints constraints = layout.getConstraints(parent.getComponent(i));
            if (i % cols == 0) // Start of new row.
            {
                lastRowConstraints = lastConstraints;
                constraints.setX(initialXSpring);
            }
            else // X position depends on previous component.
            {
                constraints.setX(Spring.sum(lastConstraints.getConstraint(SpringLayout.EAST),
                                            xPadSpring));
            }

            if (i / cols == 0) // First row.
            {
                constraints.setY(initialYSpring);
            }
            else // Y position depends on previous row.
            {
                constraints.setY(Spring.sum(lastRowConstraints.getConstraint(SpringLayout.SOUTH),
                                            yPadSpring));
            }
            lastConstraints = constraints;
        }

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

    {
        if (!(parent.getLayout() instanceof SpringLayout))
        {
            throw new IllegalArgumentException("The first argument to makeCompactGrid must use SpringLayout.");
        }
        SpringLayout layout = (SpringLayout) parent.getLayout();

        // Align all cells in each column and make them the same width.
        Spring x = Spring.constant(initialX);
        for (int c = 0; c < columns; c++)
        {
            Spring width = Spring.constant(0);
            for (int r = 0; r < rows; r++)
            {
                width = Spring.max(width,
                                   getConstraintsForCell(r, c, parent, columns).getWidth());
            }
            for (int r = 0; r < rows; r++)
            {
                SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, columns);
                constraints.setX(x);
                constraints.setWidth(width);
            }
            x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
        }

        // Align all cells in each row and make them the same height.
        Spring y = Spring.constant(initialY);
        for (int r = 0; r < rows; r++)
        {
            Spring height = Spring.constant(0);
            for (int c = 0; c < columns; c++)
            {
                height = Spring.max(height,
                                    getConstraintsForCell(r, c, parent, columns).getHeight());
            }
            for (int c = 0; c < columns; c++)
            {
                SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, columns);
                constraints.setY(y);
                constraints.setHeight(height);
            }
            y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
        }

        // Set the parent's size.
        SpringLayout.Constraints parentConstraints = layout.getConstraints(parent);
        parentConstraints.setConstraint(SpringLayout.SOUTH, y);
        parentConstraints.setConstraint(SpringLayout.EAST, x);
    }
View Full Code Here

    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$ProxySpring

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.