Digital Sound & Music: Concepts, Applications, & Science, Chapter 3, last updated 6/25/2013
52
79 augTriButton.setActionCommand("augmeTri");
80
81 JRadioButton dimTriButton = new JRadioButton("Diminished Triad");
82 dimTriButton.setActionCommand("diminTri");
83
84 ButtonGroup group = new ButtonGroup();
85 group.add(maj7thButton);
86 group.add(min7thButton);
87 group.add(dom7thButton);
88 group.add(dim7thButton);
89 group.add(majTriButton);
90 group.add(minTriButton);
91 group.add(augTriButton);
92 group.add(dimTriButton);
93
94 maj7thButton.addActionListener(this);
95 min7thButton.addActionListener(this);
96 dom7thButton.addActionListener(this);
97 dim7thButton.addActionListener(this);
98 majTriButton.addActionListener(this);
99 minTriButton.addActionListener(this);
100 augTriButton.addActionListener(this);
101 dimTriButton.addActionListener(this);
102
103 JPanel radioPanel = new JPanel(new GridLayout(0, 1));
104 radioPanel.add(maj7thButton);
105 radioPanel.add(min7thButton);
106 radioPanel.add(dom7thButton);
107 radioPanel.add(dim7thButton);
108 radioPanel.add(majTriButton);
109 radioPanel.add(minTriButton);
110 radioPanel.add(augTriButton);
111 radioPanel.add(dimTriButton);
112
113 add(radioPanel, BorderLayout.LINE_START);
114 setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
115 }
116
117 public static void main(String[] args) {
118 javax.swing.SwingUtilities.invokeLater(new Runnable() {
119 public void run() {
120 ShowWindow();
121 }
122 });
123 }
124
125 private static void ShowWindow() {
126 JFrame frame = new JFrame("Chords App");
127 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
128
129 JComponent newContentPane = new ChordApp();
130 newContentPane.setOpaque(true); //content panes must be opaque
131 frame.setContentPane(newContentPane);
132
133 frame.pack();
134 frame.setVisible(true);
135 }
Previous Page Next Page