use of javax.swing.JSeparator in project pcgen by PCGen.
the class GMGenSystem method createToolsMenu.
// Create tools menu
private void createToolsMenu() {
toolsMenu = new JMenu();
toolsSeparator1 = new JSeparator();
versionToolsItem = new JMenuItem();
CommonMenuText.name(toolsMenu, PCGenActionMap.MNU_TOOLS);
toolsMenu.addMenuListener(this);
//$NON-NLS-1$
CommonMenuText.name(versionToolsItem, "mnuGetNew");
toolsMenu.add(versionToolsItem);
toolsMenu.add(toolsSeparator1);
systemMenuBar.add(toolsMenu);
}
use of javax.swing.JSeparator in project pcgen by PCGen.
the class Initiative method initComponents.
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
private void initComponents() {
//GEN-BEGIN:initComponents
tablePopup = new javax.swing.JPopupMenu();
tablePopupCBNumber = new javax.swing.JCheckBoxMenuItem();
tablePopupCBName = new javax.swing.JCheckBoxMenuItem();
tablePopupCBPlayer = new javax.swing.JCheckBoxMenuItem();
tablePopupCBStatus = new javax.swing.JCheckBoxMenuItem();
tablePopupCBPlus = new javax.swing.JCheckBoxMenuItem();
tablePopupCBInitiative = new javax.swing.JCheckBoxMenuItem();
tablePopupCBDuration = new javax.swing.JCheckBoxMenuItem();
tablePopupCBHP = new javax.swing.JCheckBoxMenuItem();
tablePopupCBHPMax = new javax.swing.JCheckBoxMenuItem();
tablePopupCBType = new javax.swing.JCheckBoxMenuItem();
final javax.swing.JToolBar topToolbar = new javax.swing.JToolBar();
final javax.swing.JPanel buttonPanelTop = new javax.swing.JPanel();
bRoll = new javax.swing.JButton();
final JButton bAddCombatant = new JButton();
bNextInit = new javax.swing.JButton();
final JButton bRefocus = new JButton();
bCombatantReRoll = new javax.swing.JButton();
bDelete = new javax.swing.JButton();
final javax.swing.JPanel jPanel2 = new javax.swing.JPanel();
lCounter = new javax.swing.JLabel();
jSplitPane1 = new FlippingSplitPane();
final javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
final javax.swing.JScrollPane jScrollEvents = new javax.swing.JScrollPane();
combatantTable = new javax.swing.JTable();
tpaneInfo = new javax.swing.JTabbedPane();
tpCombatInfo = new javax.swing.JTextArea();
tpCombatInfo.setName("Events");
bottomToolbar = new javax.swing.JToolBar();
tablePopupCBNumber.setText("#");
tablePopupCBNumber.addActionListener(this::TablePopupActionPerformed);
tablePopup.add(tablePopupCBNumber);
tablePopupCBName.setText("Name");
tablePopupCBName.addActionListener(this::TablePopupActionPerformed);
tablePopup.add(tablePopupCBName);
tablePopupCBPlayer.setText("Player");
tablePopupCBPlayer.addActionListener(this::TablePopupActionPerformed);
tablePopup.add(tablePopupCBPlayer);
tablePopupCBStatus.setText("Status");
tablePopupCBStatus.addActionListener(this::TablePopupActionPerformed);
tablePopup.add(tablePopupCBStatus);
tablePopupCBPlus.setText("Plus");
tablePopupCBPlus.addActionListener(this::TablePopupActionPerformed);
tablePopup.add(tablePopupCBPlus);
tablePopupCBInitiative.setText("Initiative");
tablePopupCBInitiative.addActionListener(this::TablePopupActionPerformed);
tablePopup.add(tablePopupCBInitiative);
tablePopupCBDuration.setText("Duration");
tablePopupCBDuration.addActionListener(this::TablePopupActionPerformed);
tablePopup.add(tablePopupCBDuration);
tablePopupCBHP.setText("HP");
tablePopupCBHP.setEnabled(false);
tablePopupCBHP.addActionListener(this::TablePopupActionPerformed);
tablePopup.add(tablePopupCBHP);
tablePopupCBHPMax.setText("HP Max");
tablePopupCBHPMax.setEnabled(false);
tablePopupCBHPMax.addActionListener(this::TablePopupActionPerformed);
tablePopup.add(tablePopupCBHPMax);
tablePopupCBType.setText("Type");
tablePopupCBType.addActionListener(this::TablePopupActionPerformed);
tablePopup.add(tablePopupCBType);
setLayout(new java.awt.BorderLayout());
setPreferredSize(new java.awt.Dimension(700, 600));
buttonPanelTop.setLayout(new javax.swing.BoxLayout(buttonPanelTop, javax.swing.BoxLayout.X_AXIS));
bAddCombatant.setText("Add Combatant");
bAddCombatant.addActionListener(this::bAddCombatantActionPerformed);
buttonPanelTop.add(bAddCombatant);
bDuplicateCombatant.setText("Duplicate");
bDuplicateCombatant.setEnabled(false);
bDuplicateCombatant.addActionListener(this::bDuplicateCombatantActionPerformed);
bDelete.setText("Delete");
bDelete.addActionListener(this::bDeleteActionPerformed);
buttonPanelTop.add(bDelete);
buttonPanelTop.add(bDuplicateCombatant);
buttonPanelTop.add(new JSeparator());
bRoll.setText("Start Combat");
bRoll.addActionListener(this::bRollActionPerformed);
buttonPanelTop.add(bRoll);
bCombatantReRoll.setText("Roll");
bCombatantReRoll.addActionListener(this::bCombatantReRollActionPerformed);
buttonPanelTop.add(bCombatantReRoll);
bNextInit.setText("Next Initiative");
bNextInit.addActionListener(this::bNextInitActionPerformed);
buttonPanelTop.add(bNextInit);
buttonPanelTop.add(new JSeparator());
bRefocus.setText("Refocus");
bRefocus.addActionListener(this::bRefocusActionPerformed);
buttonPanelTop.add(bRefocus);
buttonPanelTop.add(new JSeparator());
bRefresh.setText("Refresh Tabs");
bRefresh.addActionListener(evt -> {
refreshTable();
refreshTabs();
});
buttonPanelTop.add(bRefresh);
topToolbar.add(buttonPanelTop);
topToolbar.add(jPanel2);
topToolbar.add(lCounter);
add(topToolbar, java.awt.BorderLayout.NORTH);
jSplitPane1.setDividerLocation(400);
jSplitPane1.setOneTouchExpandable(true);
jSplitPane1.setPreferredSize(new java.awt.Dimension(800, 405));
combatantTable.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mousePressed(java.awt.event.MouseEvent e) {
combatantTableMousePressed(e);
}
@Override
public void mouseReleased(java.awt.event.MouseEvent e) {
combatantTableMouseReleased(e);
}
});
combatantTable.addPropertyChangeListener(this::combatantTablePropertyChange);
combatantTable.getSelectionModel().addListSelectionListener(e -> {
boolean hasSelection = combatantTable.getSelectedRow() > -1;
bDuplicateCombatant.setEnabled(hasSelection);
bDelete.setEnabled(hasSelection);
bCombatantReRoll.setEnabled(hasSelection);
});
jScrollPane1.setViewportView(combatantTable);
jScrollEvents.setViewportView(tpCombatInfo);
jSplitPane1.setLeftComponent(jScrollPane1);
tpaneInfo.addTab("Events", jScrollEvents);
jSplitPane1.setRightComponent(tpaneInfo);
add(jSplitPane1, java.awt.BorderLayout.CENTER);
add(bottomToolbar, java.awt.BorderLayout.SOUTH);
bottomToolbar.add(bOpposedSkill);
}
use of javax.swing.JSeparator in project ChatGameFontificator by GlitchCog.
the class ControlPanelEmoji method build.
@Override
protected void build() {
enableAll = new JCheckBox("Enable Emoji");
enableAnimation = new JCheckBox("Enable Animation");
enableTwitchBadges = new JCheckBox("Enable Twitch Badges");
enableFfzBadges = new JCheckBox("Enable FrankerFaceZ Badges");
progressPanel = new EmojiLoadProgressPanel(chat, this);
emojiScaleToLineHeight = new JCheckBox("Relative to Line Height");
emojiScale = new LabeledSlider("Emoji Scale", "%", ConfigEmoji.MIN_SCALE, ConfigEmoji.MAX_SCALE, 100, 3);
badgeScaleToLineHeight = new JCheckBox("Relative to Line Height");
badgeScale = new LabeledSlider("Badge Scale", "%", ConfigEmoji.MIN_SCALE, ConfigEmoji.MAX_SCALE, 100, 3);
badgeHeightOffset = new LabeledSlider("Badge Height Offset", "pixels", ConfigEmoji.MIN_BADGE_OFFSET, ConfigEmoji.MAX_BADGE_OFFSET, 0, 3);
emojiLoadingDisplayStratLabel = new JLabel("Emoji Loading Display Strategy:");
emojiLoadingDisplayStrat = new JComboBox<EmojiLoadingDisplayStragegy>(EmojiLoadingDisplayStragegy.values());
enableTwitch = new JCheckBox("Enable Twitch Emotes");
cacheTwitch = new JCheckBox("Cache Global Twitch Emotes");
enableFrankerFaceZ = new JCheckBox("Enable FrankerFaceZ Emotes");
cacheFrankerFaceZ = new JCheckBox("Cache FrankerFaceZ Emotes");
enableBetterTtv = new JCheckBox("Enable BetterTTV Emotes");
cacheBetterTtv = new JCheckBox("Cache BetterTTV Emotes");
emojiScale.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
config.setEmojiScale(emojiScale.getValue());
chat.repaint();
}
});
badgeScale.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
config.setBadgeScale(badgeScale.getValue());
chat.repaint();
}
});
badgeHeightOffset.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
config.setBadgeHeightOffset(badgeHeightOffset.getValue());
chat.repaint();
}
});
emojiLoadingDisplayStrat.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
config.setDisplayStrategy((EmojiLoadingDisplayStragegy) emojiLoadingDisplayStrat.getSelectedItem());
chat.repaint();
}
});
// This action listener is for loading emotes and badges whenever a checkbox is checked while connected
ActionListener cbal = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JCheckBox source = (JCheckBox) e.getSource();
if (bot.isConnected()) {
Set<EmojiJob> jobsToRun = new HashSet<EmojiJob>();
Set<EmojiJob> jobsToCancel = new HashSet<EmojiJob>();
final boolean clickAll = enableAll.equals(source);
final boolean clickFfzLoad = clickAll || enableFrankerFaceZ.equals(source);
final boolean clickFfzCache = clickAll || cacheFrankerFaceZ.equals(source);
final boolean clickBttvLoad = clickAll || enableBetterTtv.equals(source);
final boolean clickBttvCache = clickAll || cacheBetterTtv.equals(source);
// Badges is independent of enableAll
final boolean clickTwitchBadges = !config.isTwitchBadgesLoaded(getConnectChannel()) && enableTwitchBadges.equals(source);
final boolean clickFfzBadges = !config.isFfzBadgesLoaded(getConnectChannel()) && enableFfzBadges.equals(source);
final String oauth = fProps.getProperty(FontificatorProperties.KEY_IRC_AUTH);
if (clickFfzLoad && !config.isFfzLoaded(getConnectChannel())) {
EmojiJob jobA = new EmojiJob(oauth, EmojiType.FRANKERFACEZ_CHANNEL, EmojiOperation.LOAD, getConnectChannel());
EmojiJob jobB = new EmojiJob(oauth, EmojiType.FRANKERFACEZ_GLOBAL, EmojiOperation.LOAD);
if (enableAll.isSelected() && enableFrankerFaceZ.isSelected()) {
jobsToRun.add(jobA);
jobsToRun.add(jobB);
} else {
jobsToCancel.add(jobA);
jobsToCancel.add(jobB);
}
}
if (clickBttvLoad && !config.isBttvLoaded(getConnectChannel())) {
EmojiJob jobA = new EmojiJob(oauth, EmojiType.BETTER_TTV_CHANNEL, EmojiOperation.LOAD, getConnectChannel());
EmojiJob jobB = new EmojiJob(oauth, EmojiType.BETTER_TTV_GLOBAL, EmojiOperation.LOAD);
if (enableAll.isSelected() && enableBetterTtv.isSelected()) {
jobsToRun.add(jobA);
jobsToRun.add(jobB);
} else {
jobsToCancel.add(jobA);
jobsToCancel.add(jobB);
}
}
if (clickFfzCache && !config.isFfzCached()) {
EmojiJob jobA = new EmojiJob(oauth, EmojiType.FRANKERFACEZ_CHANNEL, EmojiOperation.CACHE);
EmojiJob jobB = new EmojiJob(oauth, EmojiType.FRANKERFACEZ_GLOBAL, EmojiOperation.CACHE);
if (enableAll.isSelected() && cacheFrankerFaceZ.isSelected()) {
jobsToRun.add(jobA);
jobsToRun.add(jobB);
} else {
jobsToCancel.add(jobA);
jobsToCancel.add(jobB);
}
}
if (clickBttvCache && !config.isBttvCached()) {
EmojiJob jobA = new EmojiJob(oauth, EmojiType.BETTER_TTV_CHANNEL, EmojiOperation.CACHE);
EmojiJob jobB = new EmojiJob(oauth, EmojiType.BETTER_TTV_GLOBAL, EmojiOperation.CACHE);
if (enableAll.isSelected() && cacheBetterTtv.isSelected()) {
jobsToRun.add(jobA);
jobsToRun.add(jobB);
} else {
jobsToCancel.add(jobA);
jobsToCancel.add(jobB);
}
}
if (clickTwitchBadges && !config.isTwitchBadgesLoaded(getConnectChannel())) {
EmojiJob job = new EmojiJob(oauth, EmojiType.TWITCH_BADGE, EmojiOperation.LOAD, getConnectChannel());
// No check for enable all here, because badges are independent of the emoji enableAll toggle
if (enableTwitchBadges.isSelected()) {
jobsToRun.add(job);
} else {
jobsToCancel.add(job);
}
}
if (clickFfzBadges && !config.isFfzBadgesLoaded(getConnectChannel())) {
EmojiJob job = new EmojiJob(oauth, EmojiType.FRANKERFACEZ_BADGE, EmojiOperation.LOAD, getConnectChannel());
// No check for enable all here, because badges are independent of the emoji enableAll toggle
if (enableFfzBadges.isSelected()) {
jobsToRun.add(job);
} else {
jobsToCancel.add(job);
}
}
loadEmojiWork(jobsToRun);
cancelEmojiWork(jobsToCancel);
if (!jobsToRun.isEmpty() && !progressPanel.isCurrentlyRunning()) {
runEmojiWork();
}
}
// These are only the checkboxes handled in fillConfigFromInput()
config.setEmojiEnabled(enableAll.isSelected());
config.setAnimationEnabled(enableAnimation.isSelected());
config.setTwitchBadgesEnabled(enableTwitchBadges.isSelected());
config.setFfzBadgesEnabled(enableFfzBadges.isSelected());
config.setTwitchEnabled(enableTwitch.isSelected());
config.setTwitchCacheEnabled(cacheTwitch.isSelected());
config.setFfzEnabled(enableFrankerFaceZ.isSelected());
config.setFfzCacheEnabled(cacheFrankerFaceZ.isSelected());
config.setBttvEnabled(enableBetterTtv.isSelected());
config.setBttvCacheEnabled(cacheBetterTtv.isSelected());
config.setEmojiScaleToLine(emojiScaleToLineHeight.isSelected());
config.setBadgeScaleToLine(badgeScaleToLineHeight.isSelected());
resolveEnables();
chat.repaint();
}
};
enableAll.addActionListener(cbal);
enableAnimation.addActionListener(cbal);
enableTwitchBadges.addActionListener(cbal);
enableFfzBadges.addActionListener(cbal);
emojiScaleToLineHeight.addActionListener(cbal);
badgeScaleToLineHeight.addActionListener(cbal);
enableTwitch.addActionListener(cbal);
cacheTwitch.addActionListener(cbal);
enableFrankerFaceZ.addActionListener(cbal);
cacheFrankerFaceZ.addActionListener(cbal);
enableBetterTtv.addActionListener(cbal);
cacheBetterTtv.addActionListener(cbal);
// Top row containing emoji toggle, animation, and badge toggles
JPanel allEnabledPanel = new JPanel(new GridBagLayout());
GridBagConstraints allGbc = getGbc();
allGbc.weighty = 1.0;
allGbc.fill = GridBagConstraints.NONE;
allGbc.anchor = GridBagConstraints.WEST;
allGbc.weightx = 0.25;
allEnabledPanel.add(enableAll, allGbc);
allGbc.gridx++;
allEnabledPanel.add(enableAnimation, allGbc);
allGbc.gridx++;
allGbc.anchor = GridBagConstraints.EAST;
allEnabledPanel.add(enableTwitchBadges, allGbc);
allGbc.gridx++;
allEnabledPanel.add(enableFfzBadges, allGbc);
allGbc.gridx++;
scaleAndDisplayPanel = new JPanel(new GridBagLayout());
scaleAndDisplayPanel.setBorder(baseBorder);
GridBagConstraints scaleAndDisplayGbc = getGbc();
// Emoji scaling
scaleAndDisplayGbc.anchor = GridBagConstraints.CENTER;
scaleAndDisplayGbc.fill = GridBagConstraints.HORIZONTAL;
scaleAndDisplayGbc.weightx = 1.0;
scaleAndDisplayPanel.add(emojiScale, scaleAndDisplayGbc);
scaleAndDisplayGbc.gridx++;
scaleAndDisplayGbc.fill = GridBagConstraints.NONE;
scaleAndDisplayGbc.weightx = 0.0;
scaleAndDisplayPanel.add(emojiScaleToLineHeight, scaleAndDisplayGbc);
scaleAndDisplayGbc.gridx = 0;
scaleAndDisplayGbc.gridy++;
// Badge scaling
scaleAndDisplayGbc.anchor = GridBagConstraints.CENTER;
scaleAndDisplayGbc.fill = GridBagConstraints.HORIZONTAL;
scaleAndDisplayGbc.weightx = 1.0;
scaleAndDisplayPanel.add(badgeScale, scaleAndDisplayGbc);
scaleAndDisplayGbc.gridx++;
scaleAndDisplayGbc.fill = GridBagConstraints.NONE;
scaleAndDisplayGbc.weightx = 0.0;
scaleAndDisplayPanel.add(badgeScaleToLineHeight, scaleAndDisplayGbc);
scaleAndDisplayGbc.gridx = 0;
scaleAndDisplayGbc.gridy++;
scaleAndDisplayGbc.fill = GridBagConstraints.HORIZONTAL;
scaleAndDisplayGbc.gridwidth = 2;
scaleAndDisplayPanel.add(badgeHeightOffset, scaleAndDisplayGbc);
scaleAndDisplayGbc.gridy++;
scaleAndDisplayGbc.gridwidth = 2;
scaleAndDisplayGbc.weightx = 1.0;
scaleAndDisplayGbc.fill = GridBagConstraints.HORIZONTAL;
scaleAndDisplayPanel.add(new JSeparator(SwingConstants.HORIZONTAL), scaleAndDisplayGbc);
scaleAndDisplayGbc.gridy++;
JPanel bottomOfScaleDisplayPanel = new JPanel();
bottomOfScaleDisplayPanel.add(emojiLoadingDisplayStratLabel);
bottomOfScaleDisplayPanel.add(emojiLoadingDisplayStrat);
scaleAndDisplayPanel.add(bottomOfScaleDisplayPanel, scaleAndDisplayGbc);
twitchPanel = new JPanel(new GridBagLayout());
twitchPanel.setBorder(BorderFactory.createTitledBorder(baseBorder, "Twitch Emotes"));
GridBagConstraints twitchGbc = getGbc();
twitchPanel.add(enableTwitch, twitchGbc);
twitchGbc.gridy++;
twitchPanel.add(cacheTwitch, twitchGbc);
twitchGbc.gridy++;
frankerPanel = new JPanel(new GridBagLayout());
frankerPanel.setBorder(BorderFactory.createTitledBorder(baseBorder, "FrankerFaceZ Emotes"));
GridBagConstraints frankerGbc = getGbc();
frankerPanel.add(enableFrankerFaceZ, frankerGbc);
frankerGbc.gridy++;
frankerPanel.add(cacheFrankerFaceZ, frankerGbc);
frankerGbc.gridy++;
betterPanel = new JPanel(new GridBagLayout());
betterPanel.setBorder(BorderFactory.createTitledBorder(baseBorder, "BetterTTV Emotes"));
GridBagConstraints betterGbc = getGbc();
betterPanel.add(enableBetterTtv, betterGbc);
betterGbc.gridy++;
betterPanel.add(cacheBetterTtv, betterGbc);
betterGbc.gridy++;
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.gridwidth = 3;
add(allEnabledPanel, gbc);
gbc.gridy++;
gbc.gridwidth = 1;
add(twitchPanel, gbc);
gbc.gridx++;
add(frankerPanel, gbc);
gbc.gridx++;
add(betterPanel, gbc);
gbc.gridx++;
gbc.gridx = 0;
gbc.gridy++;
gbc.gridwidth = 3;
add(scaleAndDisplayPanel, gbc);
gbc.gridy++;
gbc.gridy++;
gbc.anchor = GridBagConstraints.SOUTH;
gbc.weighty = 1.0;
gbc.weightx = 1.0;
gbc.gridwidth = 3;
gbc.fill = GridBagConstraints.BOTH;
add(progressPanel, gbc);
gbc.gridy++;
}
use of javax.swing.JSeparator in project jdk8u_jdk by JetBrains.
the class InsetsEncapsulation method run.
@Override
public void run() {
runTest(new JLabel("hi"));
runTest(new JMenu());
runTest(new JTree());
runTest(new JTable());
runTest(new JMenuItem());
runTest(new JCheckBoxMenuItem());
runTest(new JToggleButton());
runTest(new JSpinner());
runTest(new JSlider());
runTest(Box.createVerticalBox());
runTest(Box.createHorizontalBox());
runTest(new JTextField());
runTest(new JTextArea());
runTest(new JTextPane());
runTest(new JPasswordField());
runTest(new JFormattedTextField());
runTest(new JEditorPane());
runTest(new JButton());
runTest(new JColorChooser());
runTest(new JFileChooser());
runTest(new JCheckBox());
runTest(new JInternalFrame());
runTest(new JDesktopPane());
runTest(new JTableHeader());
runTest(new JLayeredPane());
runTest(new JRootPane());
runTest(new JMenuBar());
runTest(new JOptionPane());
runTest(new JRadioButton());
runTest(new JRadioButtonMenuItem());
runTest(new JPopupMenu());
runTest(new JScrollBar());
runTest(new JScrollPane());
runTest(new JViewport());
runTest(new JSplitPane());
runTest(new JTabbedPane());
runTest(new JToolBar());
runTest(new JSeparator());
runTest(new JProgressBar());
if (!failures.isEmpty()) {
System.out.println("These classes failed");
for (final Component failure : failures) {
System.out.println(failure.getClass());
}
throw new RuntimeException("Test failed");
}
}
use of javax.swing.JSeparator in project JMRI by JMRI.
the class SystemConsole method createFrame.
/**
* Layout the console frame
*/
private void createFrame() {
// Use a JmriJFrame to ensure that we fit on the screen
frame = new JmriJFrame(Bundle.getMessage("TitleConsole"));
pref = jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class);
// Add Help menu (Windows menu automaitically added)
// NOI18N
frame.addHelpMenu("package.apps.SystemConsole", true);
// Grab a reference to the system clipboard
final Clipboard clipboard = frame.getToolkit().getSystemClipboard();
// Setup the scroll pane
JScrollPane scroll = new JScrollPane(console);
frame.add(scroll, BorderLayout.CENTER);
// Add button to allow copy to clipboard
JPanel p = new JPanel();
JButton copy = new JButton(Bundle.getMessage("ButtonCopyClip"));
copy.addActionListener((ActionEvent event) -> {
StringSelection text = new StringSelection(console.getText());
clipboard.setContents(text, text);
});
p.add(copy);
// Add button to allow console window to be closed
JButton close = new JButton(Bundle.getMessage("ButtonClose"));
close.addActionListener((ActionEvent event) -> {
frame.setVisible(false);
frame.dispose();
});
p.add(close);
JButton stackTrace = new JButton(Bundle.getMessage("ButtonStackTrace"));
stackTrace.addActionListener((ActionEvent event) -> {
performStackTrace();
});
p.add(stackTrace);
// Add checkbox to enable/disable auto-scrolling
// Use the inverted SimplePreferenceState to default as enabled
p.add(autoScroll = new JCheckBox(Bundle.getMessage("CheckBoxAutoScroll"), !pref.getSimplePreferenceState(alwaysScrollCheck)));
autoScroll.addActionListener((ActionEvent event) -> {
doAutoScroll(console, autoScroll.isSelected());
pref.setSimplePreferenceState(alwaysScrollCheck, !autoScroll.isSelected());
});
// Add checkbox to enable/disable always on top
p.add(alwaysOnTop = new JCheckBox(Bundle.getMessage("CheckBoxOnTop"), pref.getSimplePreferenceState(alwaysOnTopCheck)));
alwaysOnTop.setVisible(true);
alwaysOnTop.setToolTipText(Bundle.getMessage("ToolTipOnTop"));
alwaysOnTop.addActionListener((ActionEvent event) -> {
frame.setAlwaysOnTop(alwaysOnTop.isSelected());
pref.setSimplePreferenceState(alwaysOnTopCheck, alwaysOnTop.isSelected());
});
frame.setAlwaysOnTop(alwaysOnTop.isSelected());
// Define the pop-up menu
copySelection = new JMenuItem(Bundle.getMessage("MenuItemCopy"));
copySelection.addActionListener((ActionEvent event) -> {
StringSelection text = new StringSelection(console.getSelectedText());
clipboard.setContents(text, text);
});
popup.add(copySelection);
JMenuItem menuItem = new JMenuItem(Bundle.getMessage("ButtonCopyClip"));
menuItem.addActionListener((ActionEvent event) -> {
StringSelection text = new StringSelection(console.getText());
clipboard.setContents(text, text);
});
popup.add(menuItem);
popup.add(new JSeparator());
JRadioButtonMenuItem rbMenuItem;
// Define the colour scheme sub-menu
schemeMenu = new JMenu(rbc.getString("ConsoleSchemeMenu"));
schemeGroup = new ButtonGroup();
for (final Scheme s : schemes) {
rbMenuItem = new JRadioButtonMenuItem(s.description);
rbMenuItem.addActionListener((ActionEvent event) -> {
setScheme(schemes.indexOf(s));
});
rbMenuItem.setSelected(getScheme() == schemes.indexOf(s));
schemeMenu.add(rbMenuItem);
schemeGroup.add(rbMenuItem);
}
popup.add(schemeMenu);
// Define the wrap style sub-menu
wrapMenu = new JMenu(rbc.getString("ConsoleWrapStyleMenu"));
wrapGroup = new ButtonGroup();
rbMenuItem = new JRadioButtonMenuItem(rbc.getString("ConsoleWrapStyleNone"));
rbMenuItem.addActionListener((ActionEvent event) -> {
setWrapStyle(WRAP_STYLE_NONE);
});
rbMenuItem.setSelected(getWrapStyle() == WRAP_STYLE_NONE);
wrapMenu.add(rbMenuItem);
wrapGroup.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(rbc.getString("ConsoleWrapStyleLine"));
rbMenuItem.addActionListener((ActionEvent event) -> {
setWrapStyle(WRAP_STYLE_LINE);
});
rbMenuItem.setSelected(getWrapStyle() == WRAP_STYLE_LINE);
wrapMenu.add(rbMenuItem);
wrapGroup.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(rbc.getString("ConsoleWrapStyleWord"));
rbMenuItem.addActionListener((ActionEvent event) -> {
setWrapStyle(WRAP_STYLE_WORD);
});
rbMenuItem.setSelected(getWrapStyle() == WRAP_STYLE_WORD);
wrapMenu.add(rbMenuItem);
wrapGroup.add(rbMenuItem);
popup.add(wrapMenu);
// Bind pop-up to objects
MouseListener popupListener = new PopupListener();
console.addMouseListener(popupListener);
frame.addMouseListener(popupListener);
// Add document listener to scroll to end when modified if required
console.getDocument().addDocumentListener(new DocumentListener() {
// References to the JTextArea and JCheckBox
// of this instantiation
JTextArea ta = console;
JCheckBox chk = autoScroll;
@Override
public void insertUpdate(DocumentEvent e) {
doAutoScroll(ta, chk.isSelected());
}
@Override
public void removeUpdate(DocumentEvent e) {
doAutoScroll(ta, chk.isSelected());
}
@Override
public void changedUpdate(DocumentEvent e) {
doAutoScroll(ta, chk.isSelected());
}
});
// Add the button panel to the frame & then arrange everything
frame.add(p, BorderLayout.SOUTH);
frame.pack();
}
Aggregations