— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet389/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   385   386   387   388   389   390   391   392   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

420
 
chapter 13
import java.awt.*;
import javax.swing.*;
import javax.sound.midi.*;
import java.util.*;
import java.awt.event.*;
public class BeatBox {
JPanel mainPanel;
ArrayList checkboxList;
Sequencer sequencer;
Sequence sequence;
Track track;
JFrame theFrame;
String[] instrumentNames = {“Bass Drum”, “Closed Hi-Hat”, 
“Open Hi-Hat”,”Acoustic Snare”, “Crash Cymbal”, “Hand Clap”, 
“High Tom”, “Hi Bongo”, “Maracas”, “Whistle”, “Low Conga”, 
“Cowbell”, “Vibraslap”, “Low-mid Tom”, “High Agogo”, 
“Open Hi Conga”};
int[] instruments = {35,42,46,38,49,39,50,60,70,72,64,56,58,47,67,63};

public static void main (String[] args) {
new BeatBox2().buildGUI();
}

public void buildGUI() {
theFrame = new JFrame(“Cyber BeatBox”);
theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
BorderLayout layout = new BorderLayout();
JPanel background = new JPanel(layout);
background.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
checkboxList = new ArrayList();
Box buttonBox = new Box(BoxLayout.Y_AXIS);
JButton start = new JButton(“Start”);
start.addActionListener(new MyStartListener());
buttonBox.add(start);

JButton stop = new JButton(“Stop”);
stop.addActionListener(new MyStopListener());
buttonBox.add(stop);
JButton upTempo = new JButton(“Tempo Up”);
upTempo.addActionListener(new MyUpTempoListener());
buttonBox.add(upTempo);
JButton downTempo = new JButton(“Tempo Down”);
BeatBox 
code
We store the checkboxes in an ArrayList
These are the names of the instruments, as a String 
array, for building the GUI labels (on each row)
These represent the actual drum ‘keys’. 
The drum channel is like a piano, except 
each ‘key’ on the piano is a different drum. 
So the number ‘35’ is the key for the Bass 
drum, 42 is Closed Hi-Hat, etc.
Nothing special here, just lots of GUI 
code. You’ve seen most of it before.
An ‘empty border’ gives us a margin 
between the edges of the panel and
where the components are placed. 
Purely aesthetic.



Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   385   386   387   388   389   390   391   392   ...   555




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish