SRL Archive - General

How do I make this loop?


rj

2013-02-12 23:52:52

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Robot;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.AWTException;
import java.io.IOException;

public class MyPanel extends JPanel implements ActionListener {

private JButton jcomp1;
private JMenuBar jcomp2;
private JButton jcomp3;
private JLabel jcomp4;

public MyPanel() {

JMenu buildMenu = new JMenu ("Build");
JMenuItem startItem = new JMenuItem ("Start");
buildMenu.add (startItem);

jcomp1 = new JButton ("Start");
jcomp2 = new JMenuBar();
jcomp2.add (buildMenu);
jcomp3 = new JButton ("Settings");
jcomp4 = new JLabel ("Hit start to begin");

setPreferredSize (new Dimension (476, 296));
setLayout (null);

add (jcomp1);
jcomp1.addActionListener(this);
add (jcomp2);
add (jcomp3);
jcomp3.addActionListener(this);
add (jcomp4);
jcomp1.setBounds (225, 240, 185, 35);
jcomp2.setBounds (0, 0, 480, 35);
jcomp3.setBounds (40, 240, 185, 35);
jcomp4.setBounds (175, 195, 130, 35);
}


public static void main (String[] args) throws IOException {
JFrame frame = new JFrame ("This");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add (new MyPanel());
frame.pack();
frame.setVisible (true);
}
@Override
public void actionPerformed(ActionEvent e) {

if (e.getSource() == jcomp1) {
System.out.println("HI");
}
if (e.getSource() == jcomp1) {
System.out.println("HI");
try {
Robot r = new Robot();
Process p = Runtime.getRuntime().exec("cmd /c start http://www.google.com");
r.mouseMove(40,40);
} catch (IOException | AWTException e1) {
e1.printStackTrace();
}
}

}
}

I don't know much java lol

Btw how do you make code tags highlight java? None of these work:


[java][/java]
[code=java]

Justin

2013-02-12 23:55:24


while(true) {

code here;

}

Haven't used java in years, maybe @Flight can help?

rj

2013-02-12 23:57:47

From: Justin

while(true) {

code here;

}

Haven't used java in years, maybe @Flight can help?

I am afraid to run now, ima prank my freind with this cept it will not open up google.com :)

rj

2013-02-13 00:06:40

Just ran it had to restart computer. LOL.

@Flight Is there anyway to make java turn volume up?

Justin

2013-02-13 00:09:47

From: rjj95
Just ran it had to restart computer. LOL.

@Flight Is there anyway to make java turn volume up?


Comon man, do some google searching first.

http://stackoverflow.com/questions/953598/audio-volume-control-increase-or-decrease-in-java

What I googled: Control volume java

Echo_

2013-02-13 00:24:10

You can highlight using {highlight=java}…{/highlight}

You should also read the Java tutorials instead of coming here asking how to modify code you find on the internet:
http://docs.oracle.com/javase/tutorial/

rj

2013-02-13 16:04:19

From: Justin
Comon man, do some google searching first.

http://stackoverflow.com/questions/953598/audio-volume-control-increase-or-decrease-in-java

What I googled: Control volume java


Yup, and it sais that it cannot control the master volume, the program you linked me to controls that files volume lol

Turpinator

2013-02-13 18:54:19

Now… i dont know the compatiblity between java and calling c++ libraries, but i had found this a while back.
http://www.daveamenta.com/2011-05/programmatically-or-command-line-change-the-default-sound-playback-device-in-windows-7/

so… if you wanted, you could just make a small c++ program to do this too. i mean, it looks like the java file youve got opens up a webpage using a shell command?
easily done in c++/etc (visual studio)