Search in sources :

Example 6 with XBoxPanel

use of com.mucommander.commons.util.ui.layout.XBoxPanel in project mucommander by mucommander.

the class SplitFileDialog method initialize.

/**
 * Initializes the dialog.
 */
protected void initialize() {
    Container content = getContentPane();
    content.setLayout(new BorderLayout(0, 5));
    XAlignedComponentPanel pnlMain = new XAlignedComponentPanel(10);
    pnlMain.addRow(Translator.get("split_file_dialog.file_to_split") + ":", new JLabel(file.getName()), 0);
    String size = SizeFormat.format(file.getSize(), SizeFormat.DIGITS_FULL | SizeFormat.UNIT_LONG | SizeFormat.INCLUDE_SPACE);
    pnlMain.addRow(Translator.get("size") + ":", new JLabel(size), 10);
    edtTargetDirectory = new FilePathField(destFolder.getAbsolutePath(), 40);
    pnlMain.addRow(Translator.get("split_file_dialog.target_directory") + ":", edtTargetDirectory, 5);
    XBoxPanel pnlSize = new XBoxPanel();
    String[] sizes = new String[] { MSG_AUTO, "10 " + Translator.get("unit.mb"), "100 " + Translator.get("unit.mb"), "250 " + Translator.get("unit.mb"), "650 " + Translator.get("unit.mb"), "700 " + Translator.get("unit.mb") };
    edtSize = new JTextField();
    EditableComboBox cbSize = new EditableComboBox(edtSize, sizes);
    cbSize.setComboSelectionUpdatesTextField(true);
    cbSize.setSelectedIndex(1);
    edtSize.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            updatePartsNumber();
        }
    });
    cbSize.addComboBoxListener(new ComboBoxListener() {

        public void comboBoxSelectionChanged(SaneComboBox source) {
            updatePartsNumber();
        }
    });
    pnlSize.add(cbSize);
    pnlSize.addSpace(10);
    pnlSize.add(new JLabel(Translator.get("split_file_dialog.parts") + ":"));
    pnlSize.addSpace(5);
    spnParts = new JSpinner(new SpinnerNumberModel(1, 1, file.getSize(), 1));
    spnParts.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            if (!edtChange) {
                long parts = ((Number) spnParts.getValue()).longValue();
                long newsize = file.getSize() / parts;
                if (file.getSize() % parts != 0) {
                    newsize++;
                }
                if (getBytes() != newsize) {
                    edtSize.setText(Long.toString(newsize));
                }
            }
        }
    });
    pnlSize.add(spnParts);
    pnlMain.addRow(Translator.get("split_file_dialog.part_size") + ":", pnlSize, 0);
    cbGenerateCRC = new JCheckBox(Translator.get("split_file_dialog.generate_CRC"));
    cbGenerateCRC.setSelected(true);
    pnlMain.addRow("", cbGenerateCRC, 0);
    content.add(pnlMain, BorderLayout.CENTER);
    content.add(getPnlButtons(), BorderLayout.SOUTH);
    getRootPane().setDefaultButton(btnSplit);
    updatePartsNumber();
}
Also used : KeyAdapter(java.awt.event.KeyAdapter) JLabel(javax.swing.JLabel) FilePathField(com.mucommander.ui.text.FilePathField) SaneComboBox(com.mucommander.commons.util.ui.combobox.SaneComboBox) JTextField(javax.swing.JTextField) EditableComboBox(com.mucommander.commons.util.ui.combobox.EditableComboBox) KeyEvent(java.awt.event.KeyEvent) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JCheckBox(javax.swing.JCheckBox) Container(java.awt.Container) XAlignedComponentPanel(com.mucommander.commons.util.ui.layout.XAlignedComponentPanel) XBoxPanel(com.mucommander.commons.util.ui.layout.XBoxPanel) BorderLayout(java.awt.BorderLayout) ChangeEvent(javax.swing.event.ChangeEvent) ComboBoxListener(com.mucommander.commons.util.ui.combobox.ComboBoxListener) JSpinner(javax.swing.JSpinner) ChangeListener(javax.swing.event.ChangeListener)

Example 7 with XBoxPanel

use of com.mucommander.commons.util.ui.layout.XBoxPanel in project mucommander by mucommander.

the class PreferencesDialog method initUI.

// - UI code ----------------------------------------------------------------
// --------------------------------------------------------------------------
/**
 * Initializes the tabbed panel's UI.
 */
private void initUI() {
    // Initializes the tabbed pane.
    prefPanels = new Vector<>();
    int tabPlacement = OsFamily.MAC_OS.isCurrent() ? JTabbedPane.TOP : JTabbedPane.LEFT;
    tabbedPane = new JTabbedPane(tabPlacement);
    // Adds the tabbed pane.
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(tabbedPane, BorderLayout.CENTER);
    // Buttons panel.
    XBoxPanel buttonsPanel = new XBoxPanel();
    buttonsPanel.add(applyButton = new JButton(Translator.get("apply")));
    buttonsPanel.addSpace(20);
    buttonsPanel.add(okButton = new JButton(Translator.get("ok")));
    buttonsPanel.add(cancelButton = new JButton(Translator.get("cancel")));
    // Disable "commit buttons".
    okButton.setEnabled(false);
    applyButton.setEnabled(false);
    // Buttons listening.
    applyButton.addActionListener(this);
    okButton.addActionListener(this);
    cancelButton.addActionListener(this);
    // Aligns the button panel to the right.
    JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    tempPanel.add(buttonsPanel);
    contentPane.add(tempPanel, BorderLayout.SOUTH);
    // Selects OK when enter is pressed
    getRootPane().setDefaultButton(okButton);
}
Also used : JPanel(javax.swing.JPanel) Container(java.awt.Container) XBoxPanel(com.mucommander.commons.util.ui.layout.XBoxPanel) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton)

Aggregations

XBoxPanel (com.mucommander.commons.util.ui.layout.XBoxPanel)7 BorderLayout (java.awt.BorderLayout)3 XAlignedComponentPanel (com.mucommander.commons.util.ui.layout.XAlignedComponentPanel)2 Container (java.awt.Container)2 JButton (javax.swing.JButton)2 JLabel (javax.swing.JLabel)2 ComboBoxListener (com.mucommander.commons.util.ui.combobox.ComboBoxListener)1 EditableComboBox (com.mucommander.commons.util.ui.combobox.EditableComboBox)1 SaneComboBox (com.mucommander.commons.util.ui.combobox.SaneComboBox)1 YBoxPanel (com.mucommander.commons.util.ui.layout.YBoxPanel)1 FilePathField (com.mucommander.ui.text.FilePathField)1 FlowLayout (java.awt.FlowLayout)1 GridLayout (java.awt.GridLayout)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 JCheckBox (javax.swing.JCheckBox)1 JPanel (javax.swing.JPanel)1 JSpinner (javax.swing.JSpinner)1 JTabbedPane (javax.swing.JTabbedPane)1 JTextField (javax.swing.JTextField)1