How do I run this java program without it locking up the buttons?
Question by joe: How do I run this java program without it locking up the buttons?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class JBox extends JFrame implements ActionListener
{
private Closer Handler;
JButton play = new JButton(“Play”);
JButton stop = new JButton(“Stop”);
JButton pause = new JButton(“Pause”);
JButton mute = new JButton(“Mute”);
JMenu menu = new JMenu(“File”);
JMenu help = new JMenu(“Help”);
JTextField jam = new JTextField(“”, 10);
JMenuBar menuBar = new JMenuBar();
public JBox(String title)
{
super(title);
Handler = new Closer();
addWindowListener(Handler);
setSize(270,105);
setResizable(true);
setLocationRelativeTo(null);
menu.add(make(“Open”));
menu.add(make(“Quit”));
help.add(make(“Usage”));
help.add(make(“About”));
menuBar.add(menu);menuBar.add(help);setJMenuBar(menuBar);
Container c = getContentPane();
JPanel p1 = new JPanel();
p1.setLayout(new BorderLayout());
p1.add(stop, BorderLayout.WEST);
p1.add(pause, BorderLayout.CENTER);
p1.add(mute, BorderLayout.EAST);
jam.setBackground(new Color(20,64,123));
p1.add(jam, BorderLayout.SOUTH);
jam.setEditable(true);
p1.setBackground(new Color(29,51,253));
c.setLayout(new BorderLayout());
c.add(p1, BorderLayout.CENTER);
play.addActionListener(this);
stop.addActionListener(this);
pause.addActionListener(this);
mute.addActionListener(this);
setVisible(true);
}
//METHODS//
private void usage() {
//under construction
}
private void about() {
JOptionPane
.showMessageDialog
(null,
“Developed by ME”,
“About”,
JOptionPane.PLAIN_MESSAGE);
}
private void openFile() {
JFileChooser jfc = new JFileChooser();
int result = jfc.showOpenDialog(this);
if(result == JFileChooser.CANCEL_OPTION);{
File file = jfc.getSelectedFile();
String fl = file.getName();
String command = “qmp “+ file;
jam.setText(fl);
Runtime rt = Runtime.getRuntime();
String line=null;
try {
Process pr = rt.exec(command);
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
do {
System.out.println(line);
}
while((line=input.readLine()) != null); //{ //while((line=input.readLine()) != null)
// } //int exitVal = pr.waitFor();
//System.out.println(“Exited with error code “+exitVal);
} catch (Exception e) {}
}
}
public void play() {
try {
String[] commands = new String[]{};
commands = new String[]{“play”};
Process child = Runtime.getRuntime().exec(commands);
} catch (IOException e) {}
}
private void mute() {
try {
String[] commands = new String[]{};
commands = new String[]{“mute”};
Process child = Runtime.getRuntime().exec(commands);
} catch (IOException e) {}
}
private void stop() {
try {
Best answer:
Answer by ԃДɳїƐԼ ԃüֆƐɳՇЯїƐβ
Hello
On this page you’ll get
the requested information.
http://forums.sun.com/thread.jspa?threadID=5388803
Give your answer to this question below!
- Pros of alcohol and drug abuse?
- Cocaine doesn't cause brain damage, studies find; poverty does
- Marijuana withdrawal or depression?
- Bus service is as boring as a machine that digs tunnels. When people refuse to …
- Dark side of ND's oil boom: Meth, heroin, cartels _ all part of growing drug trade
- Do You Speak Sex?
- Report shows murder cases down in Tennessee
- Noggy stage 3- s4 in snow
- 11 years clean: Wabash Co. woman says there is a life outside of – 14 News …
- Fast Weight Loss Diet CureProgram — Video 7
- Dow Jones industrial average closes at all-time high
- Hybrid video ll 5 way switching ll live commentary
- Podcasting Genre Writer Takes On Fourteen Books And Self Publishing …