use of com.mucommander.commons.util.ui.layout.YBoxPanel in project mucommander by mucommander.
the class CommandBarDialog method createCommandBarPanel.
private JPanel createCommandBarPanel() {
YBoxPanel panel = new YBoxPanel();
panel.setBorder(BorderFactory.createTitledBorder(Translator.get("preview")));
panel.add(Box.createRigidArea(new Dimension(0, 5)));
YBoxPanel listsPanel = new YBoxPanel();
listsPanel.add(commandBarButtonsList);
listsPanel.add(commandBarAlternateButtonsList);
JScrollPane scrollPane = new JScrollPane(listsPanel, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setBorder(null);
panel.add(scrollPane);
panel.add(Box.createRigidArea(new Dimension(0, 5)));
panel.add(new JLabel("(" + Translator.get("command_bar_dialog.help") + ")"));
panel.add(Box.createRigidArea(new Dimension(0, 5)));
JPanel modifierPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
modifierField = new RecordingKeyStrokeTextField(MODIFIER_FIELD_MAX_LENGTH, CommandBarAttributes.getModifier()) {
@Override
public void setText(String t) {
super.setText(t);
componentChanged();
}
@Override
public void keyPressed(KeyEvent e) {
int pressedKeyCode = e.getKeyCode();
// Accept modifier keys only
if (pressedKeyCode == KeyEvent.VK_CONTROL || pressedKeyCode == KeyEvent.VK_ALT || pressedKeyCode == KeyEvent.VK_META || pressedKeyCode == KeyEvent.VK_SHIFT)
super.keyPressed(e);
}
};
modifierPanel.add(new JLabel(Translator.get("command_bar_customize_dialog.modifier")));
modifierPanel.add(modifierField);
panel.add(modifierPanel);
return panel;
}
use of com.mucommander.commons.util.ui.layout.YBoxPanel in project mucommander by mucommander.
the class InformationDialog method showDialog.
/**
* Brings up a dialog of the specified type and with the specified title, main and caption messages, and stack trace
* of the specified exception inside an expandable panel.
*
* @param dialogType type of dialog, see constant fields for allow values.
* @param parentComponent determines the <code>Frame</code> in which the dialog is displayed; if <code>null</code>,
* or if the parentComponent has no <code>Frame</code>, a default <code>Frame</code> is used
* @param title the dialog's title, <code>null</code> for a generic localized title, if one exists for the
* dialog type.
* @param message the main message to display in the dialog, <code>null</code> for a generic localized message, if
* one exists for the dialog type.
* @param captionMessage the caption message to display underneath the main message, <code>null</code> for none.
* @param throwable exception for which to show the stack trace, <code>null</code> for none.
*/
public static void showDialog(int dialogType, Component parentComponent, String title, String message, String captionMessage, Throwable throwable) {
Window owner = DialogToolkit.getWindowForComponent(parentComponent);
final FocusDialog dialog;
if (owner instanceof Frame)
dialog = new FocusDialog((Frame) owner, title, parentComponent);
else
dialog = new FocusDialog((Dialog) owner, title, parentComponent);
dialog.setMinimumSize(MIN_DIALOG_SIZE);
dialog.setMaximumSize(MAX_DIALOG_SIZE);
YBoxPanel mainPanel = new YBoxPanel();
InformationPane informationPane = new InformationPane(message, captionMessage, captionMessage == null ? Font.PLAIN : Font.BOLD, getInformationPaneIconId(dialogType));
mainPanel.add(informationPane);
mainPanel.addSpace(10);
JButton okButton = new JButton(Translator.get("ok"));
JPanel okPanel = DialogToolkit.createOKPanel(okButton, dialog.getRootPane(), new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
});
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
mainPanel.add(buttonPanel);
// Show the exception's stack trace in an expandable/collapsible panel
if (throwable != null) {
JTextArea detailsArea = new JTextArea();
detailsArea.setEditable(false);
// Get the stack trace as a string
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
throwable.printStackTrace(pw);
pw.close();
// Fill the area with the stack trace.
// Tabs by space characters to reduce the text's width
detailsArea.setText(sw.toString().replace('\t', ' '));
FontUtils.makeMini(detailsArea);
JScrollPane scrollPane = new JScrollPane(detailsArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
buttonPanel.add(new CollapseExpandButton(Translator.get("details"), scrollPane, false));
mainPanel.add(scrollPane);
}
buttonPanel.add(Box.createVerticalGlue());
buttonPanel.add(okPanel);
dialog.getContentPane().add(mainPanel);
// Give initial keyboard focus to the 'OK' button
dialog.setInitialFocusComponent(okButton);
// Call dispose() when dialog is closed
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.showDialog();
}
use of com.mucommander.commons.util.ui.layout.YBoxPanel in project mucommander by mucommander.
the class ShellPanel method createPreviewPanel.
private JPanel createPreviewPanel() {
JPanel panel;
YBoxPanel headerPanel;
JScrollPane scroll;
panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createTitledBorder(Translator.get("preview")));
headerPanel = new YBoxPanel();
headerPanel.add(new JLabel(Translator.get("run_dialog.run_command_description") + ":"));
headerPanel.add(historyPreview = new EditableComboBox(new JTextField("mucommander -v")));
historyPreview.addItem("mucommander -v");
historyPreview.addItem("java -version");
headerPanel.addSpace(10);
headerPanel.add(new JLabel(Translator.get("run_dialog.command_output") + ":"));
panel.add(headerPanel, BorderLayout.NORTH);
shellPreview = new JTextArea(15, 15);
panel.add(scroll = new JScrollPane(shellPreview, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
scroll.getViewport().setPreferredSize(shellPreview.getPreferredSize());
shellPreview.append(RuntimeConstants.APP_STRING);
shellPreview.append("\nThis is free software, distributed under the terms of the GNU General Public License.");
// shellPreview.setLineWrap(true);
shellPreview.setCaretPosition(0);
setForegroundColors();
setBackgroundColors();
return panel;
}
use of com.mucommander.commons.util.ui.layout.YBoxPanel in project mucommander by mucommander.
the class ShellPanel method createConfigurationPanel.
private JComponent createConfigurationPanel(int fontId, int foregroundId, int backgroundId, int selectedForegroundId, int selectedBackgroundId, JComponent fontListener) {
YBoxPanel mainPanel;
ProportionalGridPanel colorPanel;
JPanel flowPanel;
FontChooser fontChooser;
mainPanel = new YBoxPanel();
fontChooser = createFontChooser(fontId);
mainPanel.add(fontChooser);
mainPanel.addSpace(10);
addFontChooserListener(fontChooser, fontListener);
colorPanel = new ProportionalGridPanel(3);
addLabelRow(colorPanel, false);
addColorButtons(colorPanel, fontChooser, "theme_editor.normal", foregroundId, backgroundId).addPropertyChangeListener(this);
addColorButtons(colorPanel, fontChooser, "theme_editor.selected", selectedForegroundId, selectedBackgroundId).addPropertyChangeListener(this);
flowPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
flowPanel.add(colorPanel);
flowPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("theme_editor.colors")));
mainPanel.add(flowPanel);
return createScrollPane(mainPanel);
}
use of com.mucommander.commons.util.ui.layout.YBoxPanel in project mucommander by mucommander.
the class StatusBarPanel method createGeneralPanel.
private JPanel createGeneralPanel(FontChooser chooser, ColorButton foreground) {
// Initialises the color panel.
JPanel colorPanel = new ProportionalGridPanel(2);
colorPanel.add(createCaptionLabel("theme_editor.text"));
colorPanel.add(foreground);
// Wraps the color panel in a flow layout.
JPanel flowPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
flowPanel.add(colorPanel);
flowPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("theme_editor.colors")));
// Creates the general panel.
YBoxPanel mainPanel = new YBoxPanel();
mainPanel.add(chooser);
mainPanel.addSpace(10);
mainPanel.add(flowPanel);
return mainPanel;
}
Aggregations