Skip to content

Instantly share code, notes, and snippets.

@irinaaZ
Created June 24, 2018 19:48
Show Gist options
  • Save irinaaZ/2dce9334d90cac7421dbe5217bf0ab17 to your computer and use it in GitHub Desktop.
Save irinaaZ/2dce9334d90cac7421dbe5217bf0ab17 to your computer and use it in GitHub Desktop.
package JUnittasks;
import javax.swing.*;
import java.awt.*;
public class ColorSelect extends JFrame {
private final JComboBox<String> colorBox;
private static final String[] colorNames =
{"RED", "BLUE", "YELLOW"};
private final JCheckBox background;
private final JCheckBox foreground;
private final JButton ok, cancel;
public ColorSelect () {
super("ColorSelect");
setLayout(new FlowLayout());
colorBox = new JComboBox<String>(colorNames);
colorBox.setPreferredSize(new Dimension(230,20));
colorBox.setMaximumRowCount(3);
add(colorBox);
background = new JCheckBox("Background");
add(background);
foreground = new JCheckBox("Foreground");
add(foreground);
ok = new JButton("Ok");
add(ok);
cancel = new JButton("Cancel");
add(cancel);
}
public static void main(String[] args) {
ColorSelect colorSelect = new ColorSelect();
colorSelect.setSize(250, 150);
colorSelect.setResizable(false);
colorSelect.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
colorSelect.setVisible(true);
colorSelect.setLocationRelativeTo(null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment