use of com.mucommander.commons.util.ui.button.ButtonChoicePanel in project mucommander by mucommander.
the class ThemeNameDialog method init.
/**
* Initialises the dialog's UI.
*/
private void init(String name) {
YBoxPanel panel;
setMaximumSize(MAXIMUM_DIALOG_DIMENSION);
// Creates the name panel.
panel = new YBoxPanel();
panel.add(createNamePanel(name));
List<JButton> buttons = Arrays.asList(okButton = new JButton(Translator.get("ok")), cancelButton = new JButton(Translator.get("cancel")));
// Creates the button panel.
panel.add(new ButtonChoicePanel(buttons, 2, getRootPane()));
// TODO rework it to use Action based enums....
okButton.addActionListener(this);
cancelButton.addActionListener(this);
getContentPane().add(panel, BorderLayout.NORTH);
pack();
}
use of com.mucommander.commons.util.ui.button.ButtonChoicePanel in project mucommander by mucommander.
the class DialogToolkit method createButtonPanel.
/**
* Creates a button panel using the given buttons, and register the given listener for button actions.
* Buttons are disposed horizontally, aligned to the right.
*/
public static JPanel createButtonPanel(List<JButton> buttons, JRootPane rootPane, ActionListener actionListener) {
JPanel panel = new ButtonChoicePanel(buttons, 0, rootPane);
MnemonicHelper mnemonicHelper = new MnemonicHelper();
for (JButton button : buttons) {
button.setMnemonic(mnemonicHelper.getMnemonic(button.getText()));
button.addActionListener(actionListener);
panel.add(button);
}
return panel;
}
use of com.mucommander.commons.util.ui.button.ButtonChoicePanel in project mucommander by mucommander.
the class QuestionDialog method init.
protected void init(Component comp, String[] actionText, int[] actionValues, int maxNbCols) {
this.actionValues = actionValues;
// Sets minimum and maximum dimensions for this dialog
setMinimumSize(MINIMUM_DIALOG_DIMENSION);
setMaximumSize(MAXIMUM_DIALOG_DIMENSION);
mainPanel = new YBoxPanel();
if (comp != null) {
mainPanel.addSpace(5);
mainPanel.add(comp);
mainPanel.addSpace(10);
}
int nbButtons = actionText.length;
buttons = new JButton[nbButtons];
String text;
for (int i = 0; i < nbButtons; i++) {
text = actionText[i];
buttons[i] = new JButton(text);
buttons[i].addActionListener(this);
}
setInitialFocusComponent(buttons[0]);
mainPanel.add(new ButtonChoicePanel(buttons, maxNbCols, getRootPane()));
getContentPane().add(mainPanel, BorderLayout.NORTH);
}
use of com.mucommander.commons.util.ui.button.ButtonChoicePanel in project mucommander by mucommander.
the class DialogToolkit method createButtonPanel.
/**
* Creates a button panel using the given buttons, and register the given listener for button actions.
* Buttons are disposed horizontally, aligned to the right.
*/
public static JPanel createButtonPanel(JButton[] buttons, JRootPane rootPane, ActionListener actionListener) {
JPanel panel = new ButtonChoicePanel(buttons, 0, rootPane);
MnemonicHelper mnemonicHelper = new MnemonicHelper();
for (JButton button : buttons) {
button.setMnemonic(mnemonicHelper.getMnemonic(button.getText()));
button.addActionListener(actionListener);
panel.add(button);
}
return panel;
}
use of com.mucommander.commons.util.ui.button.ButtonChoicePanel in project mucommander by mucommander.
the class ProgressDialog method initUI.
private void initUI() {
Container contentPane = getContentPane();
totalProgressBar = new JProgressBar();
totalProgressBar.setStringPainted(true);
totalProgressBar.setAlignmentX(LEFT_ALIGNMENT);
currentFileLabel = new JLabel(job.getStatusString());
currentFileLabel.setAlignmentX(LEFT_ALIGNMENT);
YBoxPanel yPanel = new YBoxPanel();
// 2 progress bars
if (transferFileJob != null) {
yPanel.add(currentFileLabel);
currentFileProgressBar = new JProgressBar();
currentFileProgressBar.setStringPainted(true);
yPanel.add(currentFileProgressBar);
yPanel.addSpace(10);
totalTransferredLabel = new JLabel(Translator.get("progress_dialog.starting"));
yPanel.add(totalTransferredLabel);
yPanel.add(totalProgressBar);
} else // Single progress bar
{
yPanel.add(currentFileLabel);
yPanel.add(totalProgressBar);
}
yPanel.addSpace(10);
elapsedTimeLabel = new JLabel(Translator.get("progress_dialog.elapsed_time") + ": ");
elapsedTimeLabel.setIcon(IconManager.getIcon(IconManager.STATUS_BAR_ICON_SET, StatusBar.WAITING_ICON));
yPanel.add(elapsedTimeLabel);
if (transferFileJob != null) {
JPanel tempPanel = new JPanel(new BorderLayout());
this.currentSpeedLabel = new JLabel();
updateCurrentSpeedLabel("");
currentSpeedLabel.setIcon(IconManager.getIcon(IconManager.PROGRESS_ICON_SET, CURRENT_SPEED_ICON));
tempPanel.add(currentSpeedLabel, BorderLayout.WEST);
YBoxPanel advancedPanel = new YBoxPanel();
this.speedGraph = new SpeedGraph();
speedGraph.setPreferredSize(new Dimension(0, SPEED_GRAPH_HEIGHT));
advancedPanel.add(speedGraph);
advancedPanel.addSpace(5);
JPanel tempPanel2 = new JPanel(new BorderLayout());
this.limitSpeedCheckBox = new JCheckBox(Translator.get("progress_dialog.limit_speed") + ":", false);
limitSpeedCheckBox.addItemListener(this);
tempPanel2.add(limitSpeedCheckBox, BorderLayout.WEST);
speedChooser = new SizeChooser(true);
speedChooser.setEnabled(false);
speedChooser.addChangeListener(this);
tempPanel2.add(speedChooser, BorderLayout.EAST);
advancedPanel.add(tempPanel2);
advancedPanel.addSpace(5);
this.collapseExpandButton = new CollapseExpandButton(Translator.get("progress_dialog.advanced"), advancedPanel, true);
collapseExpandButton.setExpandedState(MuConfigurations.getPreferences().getVariable(MuPreference.PROGRESS_DIALOG_EXPANDED, MuPreferences.DEFAULT_PROGRESS_DIALOG_EXPANDED));
tempPanel.add(collapseExpandButton, BorderLayout.EAST);
yPanel.add(tempPanel);
yPanel.addSpace(5);
yPanel.add(advancedPanel);
}
closeWhenFinishedCheckBox = new JCheckBox(Translator.get("progress_dialog.close_when_finished"));
closeWhenFinishedCheckBox.setSelected(MuConfigurations.getPreferences().getVariable(MuPreference.PROGRESS_DIALOG_CLOSE_WHEN_FINISHED, MuPreferences.DEFAULT_PROGRESS_DIALOG_CLOSE_WHEN_FINISHED));
yPanel.add(closeWhenFinishedCheckBox);
yPanel.add(Box.createVerticalGlue());
contentPane.add(yPanel, BorderLayout.CENTER);
pauseResumeButton = new JButton(Translator.get("pause"), IconManager.getIcon(IconManager.PROGRESS_ICON_SET, PAUSE_ICON));
pauseResumeButton.addActionListener(this);
if (transferFileJob != null) {
skipButton = new JButton(Translator.get("skip"), IconManager.getIcon(IconManager.PROGRESS_ICON_SET, SKIP_ICON));
skipButton.addActionListener(this);
}
stopButton = new JButton(Translator.get("stop"), IconManager.getIcon(IconManager.PROGRESS_ICON_SET, STOP_ICON));
stopButton.addActionListener(this);
hideButton = new JButton(Translator.get("progress_dialog.hide"), IconManager.getIcon(IconManager.PROGRESS_ICON_SET, HIDE_ICON));
hideButton.addActionListener(this);
this.buttonsChoicePanel = new ButtonChoicePanel(skipButton == null ? Arrays.asList(pauseResumeButton, stopButton, hideButton) : Arrays.asList(pauseResumeButton, skipButton, stopButton, hideButton), 0, getRootPane());
contentPane.add(buttonsChoicePanel, BorderLayout.SOUTH);
// Cancel button receives initial focus
setInitialFocusComponent(stopButton);
// Enter triggers cancel button
getRootPane().setDefaultButton(stopButton);
}
Aggregations