use of javax.swing.JToggleButton in project ACS by ACS-Community.
the class BeanGrouper method getPauseButton.
/**
* This method pause the graphic in movement<br>
* This JButton when click do a pause of the graphic, but the sampling still running<br>
* @return javax.swing.JButton Reference to the Pause Button.
*/
private JToggleButton getPauseButton() {
if (pauseButton == null) {
pauseButton = new JToggleButton();
pauseButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource("cl/utfsm/samplingSystemUI/img/player_pause.png")));
pauseButton.setToolTipText("Pause the graphic.");
pauseButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
if (pausedGraph == false) {
for (DataPrinter i : samplers) {
i.pauseSampling(true);
}
pauseButton.setSelected(true);
pausedGraph = true;
} else {
for (DataPrinter i : samplers) {
i.pauseSampling(false);
}
pausedGraph = false;
pauseButton.setSelected(false);
}
}
});
}
return pauseButton;
}
use of javax.swing.JToggleButton in project ChatGameFontificator by GlitchCog.
the class ControlPanelDebug method build.
@Override
protected void build() {
postTestMessage = new JButton("Post Debug Message");
postTestMessage.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ctrlWindow.addManualMessage("Test", SpriteFont.NORMAL_ASCII_KEY);
}
});
postMessagesButton = new JToggleButton("Post Messages");
postRateSlider = new LabeledSlider("Post Rate ", " / min", 1, 120, 15, 3);
postClock = new Timer(60000 / postRateSlider.getValue(), new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
postRandomMessage();
}
});
postRateSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (!((JSlider) e.getSource()).getValueIsAdjusting()) {
postClock.setDelay(60000 / postRateSlider.getValue());
if (postClock.isRunning()) {
postRandomMessage();
postClock.restart();
}
}
}
});
postMessagesButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
postRandomMessage();
if (postMessagesButton.isSelected()) {
postClock.start();
} else {
postClock.stop();
}
}
});
drawTextGridBox = new JCheckBox("Draw Text Grid");
textGridColorButton = new ColorButton("Text Grid Color", new Color(0x99FF88), "Color of the border grid", this);
drawBorderGridBox = new JCheckBox("Draw Border Grid");
borderGridColorButton = new ColorButton("Border Grid Color", new Color(0x9988FF), "Color of the border grid", this);
ActionListener refreshListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (chat != null) {
chat.repaint();
}
}
};
drawTextGridBox.addActionListener(refreshListener);
drawBorderGridBox.addActionListener(refreshListener);
JPanel topPanel = new JPanel(new GridBagLayout());
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0.0;
gbc.weighty = 0.0;
gbc.fill = GridBagConstraints.NONE;
topPanel.add(postTestMessage, gbc);
gbc.gridx++;
topPanel.add(postMessagesButton, gbc);
gbc.gridx++;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
topPanel.add(postRateSlider, gbc);
gbc.gridwidth = 4;
gbc.gridx = 0;
gbc.gridy = 0;
add(topPanel, gbc);
gbc.gridy++;
gbc.gridwidth = 1;
gbc.weightx = 0.5;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(drawTextGridBox, gbc);
gbc.gridx++;
add(textGridColorButton, gbc);
gbc.gridx++;
add(drawBorderGridBox, gbc);
gbc.gridx++;
add(borderGridColorButton, gbc);
gbc.gridy++;
gbc.gridx = 0;
gbc.gridwidth = 4;
gbc.weighty = 0.1;
CollagePanel collagePanel = new CollagePanel(chat);
add(collagePanel, gbc);
gbc.gridy++;
gbc.weightx = 1.0;
gbc.weighty = 0.9;
gbc.anchor = GridBagConstraints.SOUTH;
gbc.fill = GridBagConstraints.BOTH;
gbc.gridwidth = 4;
add(logBox, gbc);
}
use of javax.swing.JToggleButton in project ChatGameFontificator by GlitchCog.
the class CharacterPicker method build.
private void build() {
setLayout(new GridLayout(12, 8));
setTitle("Character Picker");
ActionListener al = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JToggleButton tb = (JToggleButton) e.getSource();
setSelectedChar(tb.getText().charAt(0));
setVisible(false);
}
};
buttonGroup = new ButtonGroup() {
private static final long serialVersionUID = 1L;
@Override
public void setSelected(ButtonModel model, boolean selected) {
if (selected) {
super.setSelected(model, selected);
} else {
clearSelection();
}
}
};
charButtons = new JToggleButton[96];
for (int i = 0; i < charButtons.length; i++) {
charButtons[i] = new JToggleButton(Character.toString((char) (i + 32)));
charButtons[i].addActionListener(al);
buttonGroup.add(charButtons[i]);
add(charButtons[i]);
}
pack();
setResizable(false);
}
use of javax.swing.JToggleButton 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.JToggleButton in project logging-log4j2 by apache.
the class ClientGui method scroll.
private JScrollPane scroll(final JTextArea text) {
final JToggleButton toggleButton = new JToggleButton();
toggleButton.setAction(new AbstractAction() {
private static final long serialVersionUID = -4214143754637722322L;
@Override
public void actionPerformed(final ActionEvent e) {
final boolean wrap = toggleButton.isSelected();
text.setLineWrap(wrap);
}
});
toggleButton.setToolTipText("Toggle line wrapping");
final JScrollPane scrollStatusLog = new //
JScrollPane(//
text, //
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollStatusLog.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, toggleButton);
return scrollStatusLog;
}
Aggregations