Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 25th, 2004, 1:43 PM   #1
T3FLoN
Newbie
 
Join Date: Nov 2004
Posts: 21
Rep Power: 0 T3FLoN is on a distinguished road
Hi, i added a mouse listener to my program which is meant to adjust the volume.
Im using 2 JButtons and i have a JLabel witch displays the current volume setting, but inorder to change the value i need to repeadidly click the button to increment or decrement it.
I've done that using an ActionListener, now i implemented the MouseListener cause i want to be able to just hold the button and have it increment till i release it.
Im still in the learning phase of JAVA and this step isnt one of the requirments to my program but given to me as an extra step to keep me busy lol.
Well truth is i got my mouse listener working, i know this by using printlns to display messages as each mouse event happens, but i got no idea how to acomplish what im trying to do.
Ive searched and found many tutorials but none relate to what i want.
So if anyone can shed some light on how id do this, I thank you in advance.
__________________
<span style='font-family:Courier'><span style='font-size:12pt;line-height:100%'><span style='color:orange'>☼☼☼ Just kill em all, and let God sort em out. ☼☼☼</span></span></span>
T3FLoN is offline   Reply With Quote
Old Nov 25th, 2004, 1:46 PM   #2
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Can we see code of what you've got so far?
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Nov 25th, 2004, 1:57 PM   #3
T3FLoN
Newbie
 
Join Date: Nov 2004
Posts: 21
Rep Power: 0 T3FLoN is on a distinguished road
Ya since this is a completed skool project just missing this last feauter i mentioned heres the code for it:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;

class Radio extends JFrame implements ActionListener, MouseListener{

	// volume control
	private JLabel volLbl;
	private JLabel numVolLbl;
	private int numVol = 20;
	private JButton volUp;
	private JButton volDown;

	// tune control
	private JLabel tune;
	private JButton tuneUp;
	private JButton tuneDown;

	// preset control
	private JButton pre1;
	private JButton pre2;
	private JButton pre3;
	private JButton pre4;
	private JButton pre5;
	private JLabel presetLbl;
	private JLabel presetNumLbl;
	private String preset1 = "";
	private String preset2 = "";
	private String preset3 = "";
	private String preset4 = "";
	private String preset5 = "";

	//memory control
	private JButton mem;
	private boolean memPressed = false;


	//function control
	private JButton func;
	private boolean funcPressed = false;

	//display area
	private JLabel mainDisplay;
	private double frequency = 95.9;
  private JLabel nameLbl;
	Font displayFont = new Font("Courier New",Font.BOLD,32);

	private Container c;//declaring container

	String tuneList[]={"88.5","89.3","90.3","91.3","91.9","92.5","93.5","94.3","95.1",
    "95.9","96.9","97.7","98.5","99.5","99.9","100.7","101.5","102.3",
       "105.7","107.3"};

	String nameList[]={"CBME","CISM","CKUT","CIRA","WAMC","CFQR","CBM","CKMF","CBF","CJFM",
    "CKOI","CHOM","CKOO","CJPX","WBTZ","CBFFM","CIBL","CINQ","CFGL","CITE"};

//==============================TIME CYCLE===============================================
// this is the only way i figured out how to make the time cycle
	javax.swing.Timer t = new javax.swing.Timer(1000,
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Calendar now = Calendar.getInstance();
            int h = now.get(Calendar.HOUR_OF_DAY);
            String m = ""+now.get(Calendar.MINUTE);
            if(m.length()== 1){
     m = "0"+m;
    }
            mainDisplay.setText("" + h + ":" + m);
          }
        });

//=======================================================================================

	public static void main(String args[]){
 Radio myRadio = new Radio();// created a radio object named myRadio
	}

//=======================================================================================

	public Radio(){

	// JFrame's properties
 this.setBounds(100,100,400,240);
 this.setResizable(false);
 this.setTitle("Radio");

	// volume properties
 volLbl = new JLabel("Volume");
 volLbl.setBounds(30,85,60,40);
 volLbl.setForeground(Color.green);

 numVolLbl = new JLabel(""+numVol);
 numVolLbl.setBounds(40,130,40,40);
 numVolLbl.setForeground(Color.green);

 volUp = new JButton("UP");
 volUp.setBounds(20,115,65,25);
// volUp.addActionListener(this);
 volUp.addMouseListener(this);
 volUp.setForeground(Color.green);
 volUp.setBackground(Color.darkGray);
 volUp.setFocusable(false);

 volDown = new JButton("DWN");
 volDown.setBounds(20,160,65,25);
// volDown.addActionListener(this);
 volDown.addMouseListener(this);
 volDown.setForeground(Color.green);
 volDown.setBackground(Color.darkGray);
 volDown.setFocusable(false);

	// tuner properties
 tune = new JLabel("Tune");
 tune.setBounds(40,10,40,40);
 tune.setForeground(Color.green);

 tuneUp = new JButton("UP");
 tuneUp.setBounds(20,40,65,25);
 tuneUp.addActionListener(this);
 tuneUp.setForeground(Color.green);
 tuneUp.setBackground(Color.darkGray);
 tuneUp.setFocusable(false);

 tuneDown = new JButton("DWN");
 tuneDown.setBounds(20,65,65,25);
 tuneDown.addActionListener(this);
 tuneDown.setForeground(Color.green);
 tuneDown.setBackground(Color.darkGray);
 tuneDown.setFocusable(false);

	// preset properties
 pre1 = new JButton("1");
 pre1.setBounds(100,125,50,50);
 pre1.addActionListener(this);
 pre1.setForeground(Color.green);
 pre1.setBackground(Color.darkGray);
 pre1.setFocusable(false);

 pre2 = new JButton("2");
 pre2.setBounds(155,125,50,50);
 pre2.addActionListener(this);
 pre2.setForeground(Color.green);
 pre2.setBackground(Color.darkGray);
 pre2.setFocusable(false);

 pre3 = new JButton("3");
 pre3.setBounds(210,125,50,50);
 pre3.addActionListener(this);
 pre3.setForeground(Color.green);
 pre3.setBackground(Color.darkGray);
 pre3.setFocusable(false);

 pre4 = new JButton("4");
 pre4.setBounds(265,125,50,50);
 pre4.addActionListener(this);
 pre4.setForeground(Color.green);
 pre4.setBackground(Color.darkGray);
 pre4.setFocusable(false);

 pre5 = new JButton("5");
 pre5.setBounds(320,125,50,50);
 pre5.addActionListener(this);
 pre5.setForeground(Color.green);
 pre5.setBackground(Color.darkGray);
 pre5.setFocusable(false);

 presetLbl = new JLabel("Preset:");
 presetLbl.setBounds(260,45,60,40);
 presetLbl.setForeground(Color.green);

 presetNumLbl = new JLabel("");
 presetNumLbl.setBounds(305,50,20,20);
 presetNumLbl.setForeground(Color.green);

	// memory properties
 mem = new JButton("M");
 mem.setBounds(175,90,45,25);
 mem.addActionListener(this);
 mem.setForeground(Color.green);
 mem.setBackground(Color.darkGray);
 mem.setFocusable(false);

	// function propeties
 func = new JButton("F");
 func.setBounds(240,90,45,25);
 func.addActionListener(this);
 func.setForeground(Color.green);
 func.setBackground(Color.darkGray);
 func.setFocusable(false);

	// main display properties
 mainDisplay = new JLabel(""+frequency);
 mainDisplay.setBounds(140,30,100,50);
 mainDisplay.setFont(displayFont);
 mainDisplay.setForeground(Color.green);
 mainDisplay.setBackground(Color.black);

 nameLbl = new JLabel("BOO");
 nameLbl.setBounds(260,30,60,40);
 nameLbl.setForeground(Color.green);
 nameLbl.setBackground(Color.black);

	// adding my content
 c = getContentPane();
 c.setLayout(null);
 c.setBackground(Color.black);
 c.add(volLbl);
 c.add(numVolLbl);
 c.add(volUp);
 c.add(volDown);
 c.add(tune);
 c.add(tuneUp);
 c.add(tuneDown);
 c.add(pre1);
 c.add(pre2);
 c.add(pre3);
 c.add(pre4);
 c.add(pre5);
 c.add(presetLbl);
 c.add(presetNumLbl);
 c.add(mem);
 c.add(mainDisplay);
 c.add(func);
 c.add(nameLbl);

 this.setVisible(true);
	}

//======================================================================================

	public void actionPerformed(ActionEvent e) {

//===============================VOLUME ADJUSTING UP====================================

 if(e.getSource() == volUp && !numVolLbl.getText().equals("100"))
 {
 	numVolLbl.setText(""+ ++numVol); //increment volume
 	if(numVolLbl.getText().equals("100")){
  volUp.setEnabled(false);
 	}
 	if(!numVolLbl.getText().equals("0")){ // disables button when limit reached
  volDown.setEnabled(true);
 	}
 }

//===============================VOLUME ADJUSTING DOWN==================================


 if(e.getSource() == volDown && !numVolLbl.getText().equals("0"))
 {
 	numVolLbl.setText(""+ --numVol); //decrement volume
 	if(numVolLbl.getText().equals("0")){
  volDown.setEnabled(false);
 	}
 	if(!numVolLbl.getText().equals("100")){ // disables button when limit reached
  volUp.setEnabled(true);
 	}
 }

//===============================TUNE ADJUSTING UP======================================

 if(e.getSource() == tuneUp){
 	presetNumLbl.setText("");
 	if(mainDisplay.getText().equals("109.0")){ // setting frequency limit
  mainDisplay.setText("87.5");
  frequency = 87.5;
 	}
 	else{ // incrementing frequency
  double tempFrq = frequency;
  tempFrq*=10;
  tempFrq++;
  frequency = tempFrq/=10;
  mainDisplay.setText(""+frequency);
 	}
 	if(funcPressed){ // returns back to tuner view
  mem.setEnabled(true);
  mainDisplay.setText(""+frequency);
  funcPressed = false;
 	}
 }
//===============================TUNE ADJUSTING DOWN=====================================

 if(e.getSource() == tuneDown){
 	presetNumLbl.setText("");
 	if(mainDisplay.getText().equals("87.5")){ // setting frequency limit
  mainDisplay.setText("109.0");
  frequency = 109.0;
 	}
 	else{ // incrementing frequency
  double tempFrq = frequency;
  tempFrq*=10;
  tempFrq--;
  frequency = tempFrq/=10;
  mainDisplay.setText(""+frequency);
 	}
 	if(funcPressed){ // returns back to tuner view
  mem.setEnabled(true);
  mainDisplay.setText(""+frequency);
  funcPressed = false;
 	}
 }

//==========================STATION NAME SETTING==========================================

 if(e.getSource() == tuneDown || e.getSource() == tuneUp){
 	for(int x=0; x<tuneList.length; x++){
  if(tuneList[x].equals(mainDisplay.getText())){
  	System.out.println(nameList[x]);
  	nameLbl.setText(nameList[x]);
  	break;
  }
  else{
  	nameLbl.setText("");
  }
 	}
 }

//============================PRESET ADJUSTMENT============================================

 if(e.getSource() == pre1){ //PRESET 1 ---------------------------------------------
 	if(memPressed){ // storing frequency
  preset1 = mainDisplay.getText();
  memPressed = false;
  func.setEnabled(true);
 	}
 	else if(!preset1.equals("") && memPressed == false){ // displaying stored preset
  mainDisplay.setText(preset1);
  presetNumLbl.setText("1");
  frequency = Double.parseDouble(mainDisplay.getText());
 	}
 }
 if(e.getSource() == pre2){ //PRESET 2 ---------------------------------------------
 	if(memPressed){ // storing frequency
  preset2 = mainDisplay.getText();
  memPressed = false;
  func.setEnabled(true);
 	}
 	else if(!preset2.equals("") && memPressed == false){ // displaying stored preset
  mainDisplay.setText(preset2);
  presetNumLbl.setText("2");
  frequency = Double.parseDouble(mainDisplay.getText());
 	}
 }
 if(e.getSource() == pre3){ //PRESET 3 ---------------------------------------------
 	if(memPressed){ // storing frequency
  preset3 = mainDisplay.getText();
  memPressed = false;
  func.setEnabled(true);
 	}
 	else if(!preset3.equals("") && memPressed == false){ // displaying stored preset
  mainDisplay.setText(preset3);
  presetNumLbl.setText("3");
  frequency = Double.parseDouble(mainDisplay.getText());
 	}
 }
 if(e.getSource() == pre4){ //PRESET 4 ---------------------------------------------
 	if(memPressed){ // storing frequency
  preset4 = mainDisplay.getText();
  memPressed = false;
  func.setEnabled(true);
 	}
 	else if(!preset4.equals("") && memPressed == false){ // displaying stored preset
  mainDisplay.setText(preset4);
  presetNumLbl.setText("4");
  frequency = Double.parseDouble(mainDisplay.getText());
 	}
 }
 if(e.getSource() == pre5){ //PRESET 5 ---------------------------------------------
 	if(memPressed){ // storing frequency
  preset5 = mainDisplay.getText();
  memPressed = false;
  func.setEnabled(true);
 	}
 	else if(!preset5.equals("") && memPressed == false){ // displaying stored preset
  mainDisplay.setText(preset5);
  presetNumLbl.setText("5");
  frequency = Double.parseDouble(mainDisplay.getText());
   }
 }

//===============================MEMORY ACTION=============================================

 if(e.getSource() == mem){ // setting presets boolean
 	if(!memPressed){
    memPressed = true;
    func.setEnabled(false);
 	}
 	else{ // unsetting presets boolean
  memPressed = false;
    func.setEnabled(true);
 	}
 }

//===============================FUNCTION ACTION===========================================

 if(e.getSource() == func){ // changes mainDisplay to the time
   String[] ids = TimeZone.getAvailableIDs(-5 * 60 * 60 * 1000);
   SimpleTimeZone pdt = new SimpleTimeZone(-5 * 60 * 60 * 1000, ids[0]);
     Calendar calendar = new GregorianCalendar(pdt);
 	if(funcPressed == false){
  t.start(); // Start the timer
     funcPressed = true;
  	mem.setEnabled(false);
 	}
     else{ // changed mainDisplay to tuner view
       t.stop(); // Stop the timer
  mainDisplay.setText(""+frequency);
  funcPressed = false;
  mem.setEnabled(true);
 	}
 }
	}

//===========================MOUSE LISTENER===============================================

   public void mousePressed(MouseEvent e) {
    System.out.println("Mouse pressed;");
   }

   public void mouseReleased(MouseEvent e) {
    System.out.println("Mouse released;");
   }

   public void mouseEntered(MouseEvent e) {
    System.out.println("Mouse entered");
   }

   public void mouseExited(MouseEvent e) {
    System.out.println("Mouse exited");
   }

   public void mouseClicked(MouseEvent e) {
    System.out.println("Mouse clicked ");
    }
}
__________________
<span style='font-family:Courier'><span style='font-size:12pt;line-height:100%'><span style='color:orange'>☼☼☼ Just kill em all, and let God sort em out. ☼☼☼</span></span></span>
T3FLoN is offline   Reply With Quote
Old Nov 26th, 2004, 3:26 AM   #4
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Probably not the best way to do it, but it gets the job done.

Sorry about the ugliness of the code. While messing around with it, I changed up some of the alignment, and the tabbing at this site doesn't exactly help in making the code neat. But it works.

Nice looking program, might I add.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;

class Radio extends JFrame implements ActionListener, MouseListener{

// volume control
private JLabel volLbl;
private JLabel numVolLbl;
private int numVol = 20;
private JButton volUp;
private JButton volDown;
private int pressed = 0;
// tune control
private JLabel tune;
private JButton tuneUp;
private JButton tuneDown;

// preset control
private JButton pre1;
private JButton pre2;
private JButton pre3;
private JButton pre4;
private JButton pre5;
private JLabel presetLbl;
private JLabel presetNumLbl;
private String preset1 = "";
private String preset2 = "";
private String preset3 = "";
private String preset4 = "";
private String preset5 = "";

//memory control
private JButton mem;
private boolean memPressed = false;


//function control
private JButton func;
private boolean funcPressed = false;

//display area
private JLabel mainDisplay;
private double frequency = 95.9;
  private JLabel nameLbl;
Font displayFont = new Font("Courier New",Font.BOLD,32);

private Container c;//declaring container

String tuneList[]={"88.5","89.3","90.3","91.3","91.9","92.5","93.5","94.3","95.1",
    "95.9","96.9","97.7","98.5","99.5","99.9","100.7","101.5","102.3",
       "105.7","107.3"};

String nameList[]={"CBME","CISM","CKUT","CIRA","WAMC","CFQR","CBM","CKMF","CBF","CJFM",
    "CKOI","CHOM","CKOO","CJPX","WBTZ","CBFFM","CIBL","CINQ","CFGL","CITE"};

//==============================TIME CYCLE===============================================
// this is the only way i figured out how to make the time cycle
javax.swing.Timer t = new javax.swing.Timer(1000,
       new ActionListener() {
        public void actionPerformed(ActionEvent e) {
    
    Calendar now = Calendar.getInstance();
           int h = now.get(Calendar.HOUR_OF_DAY);
           String m = ""+now.get(Calendar.MINUTE);
           if(m.length()== 1){
    m = "0"+m;
    }
           mainDisplay.setText("" + h + ":" + m);
         }
       });


javax.swing.Timer timer = new javax.swing.Timer(1000,
       new ActionListener() {
        public void actionPerformed(ActionEvent e) {
    
 	increment();
     }
       });
       
       

//=======================================================================================

public static void main(String args[]){
 Radio myRadio = new Radio();// created a radio object named myRadio
}

//=======================================================================================

public Radio(){

// JFrame's properties
 this.setBounds(100,100,400,240);
 this.setResizable(false);
 this.setTitle("Radio");
timer.start();
// volume properties
 volLbl = new JLabel("Volume");
 volLbl.setBounds(30,85,60,40);
 volLbl.setForeground(Color.green);

 numVolLbl = new JLabel(""+numVol);
 numVolLbl.setBounds(40,130,40,40);
 numVolLbl.setForeground(Color.green);

 volUp = new JButton("UP");
 volUp.setBounds(20,115,65,25);
// volUp.addActionListener(this);
 volUp.addMouseListener(this);
 volUp.setForeground(Color.green);
 volUp.setBackground(Color.darkGray);
 volUp.setFocusable(false);

 volDown = new JButton("DWN");
 volDown.setBounds(20,160,65,25);
// volDown.addActionListener(this);
 volDown.addMouseListener(this);
 volDown.setForeground(Color.green);
 volDown.setBackground(Color.darkGray);
 volDown.setFocusable(false);

// tuner properties
 tune = new JLabel("Tune");
 tune.setBounds(40,10,40,40);
 tune.setForeground(Color.green);

 tuneUp = new JButton("UP");
 tuneUp.setBounds(20,40,65,25);
 tuneUp.addActionListener(this);
 tuneUp.setForeground(Color.green);
 tuneUp.setBackground(Color.darkGray);
 tuneUp.setFocusable(false);

 tuneDown = new JButton("DWN");
 tuneDown.setBounds(20,65,65,25);
 tuneDown.addActionListener(this);
 tuneDown.setForeground(Color.green);
 tuneDown.setBackground(Color.darkGray);
 tuneDown.setFocusable(false);

// preset properties
 pre1 = new JButton("1");
 pre1.setBounds(100,125,50,50);
 pre1.addActionListener(this);
 pre1.setForeground(Color.green);
 pre1.setBackground(Color.darkGray);
 pre1.setFocusable(false);

 pre2 = new JButton("2");
 pre2.setBounds(155,125,50,50);
 pre2.addActionListener(this);
 pre2.setForeground(Color.green);
 pre2.setBackground(Color.darkGray);
 pre2.setFocusable(false);

 pre3 = new JButton("3");
 pre3.setBounds(210,125,50,50);
 pre3.addActionListener(this);
 pre3.setForeground(Color.green);
 pre3.setBackground(Color.darkGray);
 pre3.setFocusable(false);

 pre4 = new JButton("4");
 pre4.setBounds(265,125,50,50);
 pre4.addActionListener(this);
 pre4.setForeground(Color.green);
 pre4.setBackground(Color.darkGray);
 pre4.setFocusable(false);

 pre5 = new JButton("5");
 pre5.setBounds(320,125,50,50);
 pre5.addActionListener(this);
 pre5.setForeground(Color.green);
 pre5.setBackground(Color.darkGray);
 pre5.setFocusable(false);

 presetLbl = new JLabel("Preset:");
 presetLbl.setBounds(260,45,60,40);
 presetLbl.setForeground(Color.green);

 presetNumLbl = new JLabel("");
 presetNumLbl.setBounds(305,50,20,20);
 presetNumLbl.setForeground(Color.green);

// memory properties
 mem = new JButton("M");
 mem.setBounds(175,90,45,25);
 mem.addActionListener(this);
 mem.setForeground(Color.green);
 mem.setBackground(Color.darkGray);
 mem.setFocusable(false);

// function propeties
 func = new JButton("F");
 func.setBounds(240,90,45,25);
 func.addActionListener(this);
 func.setForeground(Color.green);
 func.setBackground(Color.darkGray);
 func.setFocusable(false);

// main display properties
 mainDisplay = new JLabel(""+frequency);
 mainDisplay.setBounds(140,30,100,50);
 mainDisplay.setFont(displayFont);
 mainDisplay.setForeground(Color.green);
 mainDisplay.setBackground(Color.black);

 nameLbl = new JLabel("BOO");
 nameLbl.setBounds(260,30,60,40);
 nameLbl.setForeground(Color.green);
 nameLbl.setBackground(Color.black);

// adding my content
 c = getContentPane();
 c.setLayout(null);
 c.setBackground(Color.black);
 c.add(volLbl);
 c.add(numVolLbl);
 c.add(volUp);
 c.add(volDown);
 c.add(tune);
 c.add(tuneUp);
 c.add(tuneDown);
 c.add(pre1);
 c.add(pre2);
 c.add(pre3);
 c.add(pre4);
 c.add(pre5);
 c.add(presetLbl);
 c.add(presetNumLbl);
 c.add(mem);
 c.add(mainDisplay);
 c.add(func);
 c.add(nameLbl);

 this.setVisible(true);
}

//======================================================================================

public void actionPerformed(ActionEvent e) {

//===============================VOLUME ADJUSTING UP====================================

 

//===============================TUNE ADJUSTING UP======================================

 if(e.getSource() == tuneUp){
 presetNumLbl.setText("");
 if(mainDisplay.getText().equals("109.0")){ // setting frequency limit
  mainDisplay.setText("87.5");
  frequency = 87.5;
 }
 else{ // incrementing frequency
  double tempFrq = frequency;
  tempFrq*=10;
  tempFrq++;
  frequency = tempFrq/=10;
  mainDisplay.setText(""+frequency);
 }
 if(funcPressed){ // returns back to tuner view
  mem.setEnabled(true);
  mainDisplay.setText(""+frequency);
  funcPressed = false;
 }
 }
//===============================TUNE ADJUSTING DOWN=====================================

 if(e.getSource() == tuneDown){
 presetNumLbl.setText("");
 if(mainDisplay.getText().equals("87.5")){ // setting frequency limit
  mainDisplay.setText("109.0");
  frequency = 109.0;
 }
 else{ // incrementing frequency
  double tempFrq = frequency;
  tempFrq*=10;
  tempFrq--;
  frequency = tempFrq/=10;
  mainDisplay.setText(""+frequency);
 }
 if(funcPressed){ // returns back to tuner view
  mem.setEnabled(true);
  mainDisplay.setText(""+frequency);
  funcPressed = false;
 }
 }

//==========================STATION NAME SETTING==========================================

 if(e.getSource() == tuneDown || e.getSource() == tuneUp){
 for(int x=0; x<tuneList.length; x++){
  if(tuneList[x].equals(mainDisplay.getText())){
  System.out.println(nameList[x]);
  nameLbl.setText(nameList[x]);
  break;
  }
  else{
  nameLbl.setText("");
  }
 }
 }

//============================PRESET ADJUSTMENT============================================

 if(e.getSource() == pre1){ //PRESET 1 ---------------------------------------------
 if(memPressed){ // storing frequency
  preset1 = mainDisplay.getText();
  memPressed = false;
  func.setEnabled(true);
 }
 else if(!preset1.equals("") && memPressed == false){ // displaying stored preset
  mainDisplay.setText(preset1);
  presetNumLbl.setText("1");
  frequency = Double.parseDouble(mainDisplay.getText());
 }
 }
 if(e.getSource() == pre2){ //PRESET 2 ---------------------------------------------
 if(memPressed){ // storing frequency
  preset2 = mainDisplay.getText();
  memPressed = false;
  func.setEnabled(true);
 }
 else if(!preset2.equals("") && memPressed == false){ // displaying stored preset
  mainDisplay.setText(preset2);
  presetNumLbl.setText("2");
  frequency = Double.parseDouble(mainDisplay.getText());
 }
 }
 if(e.getSource() == pre3){ //PRESET 3 ---------------------------------------------
 if(memPressed){ // storing frequency
  preset3 = mainDisplay.getText();
  memPressed = false;
  func.setEnabled(true);
 }
 else if(!preset3.equals("") && memPressed == false){ // displaying stored preset
  mainDisplay.setText(preset3);
  presetNumLbl.setText("3");
  frequency = Double.parseDouble(mainDisplay.getText());
 }
 }
 if(e.getSource() == pre4){ //PRESET 4 ---------------------------------------------
 if(memPressed){ // storing frequency
  preset4 = mainDisplay.getText();
  memPressed = false;
  func.setEnabled(true);
 }
 else if(!preset4.equals("") && memPressed == false){ // displaying stored preset
  mainDisplay.setText(preset4);
  presetNumLbl.setText("4");
  frequency = Double.parseDouble(mainDisplay.getText());
 }
 }
 if(e.getSource() == pre5){ //PRESET 5 ---------------------------------------------
 if(memPressed){ // storing frequency
  preset5 = mainDisplay.getText();
  memPressed = false;
  func.setEnabled(true);
 }
 else if(!preset5.equals("") && memPressed == false){ // displaying stored preset
  mainDisplay.setText(preset5);
  presetNumLbl.setText("5");
  frequency = Double.parseDouble(mainDisplay.getText());
   }
 }

//===============================MEMORY ACTION=============================================

 if(e.getSource() == mem){ // setting presets boolean
 if(!memPressed){
   memPressed = true;
   func.setEnabled(false);
 }
 else{ // unsetting presets boolean
  memPressed = false;
   func.setEnabled(true);
 }
 }

//===============================FUNCTION ACTION===========================================

 if(e.getSource() == func){ // changes mainDisplay to the time
   String[] ids = TimeZone.getAvailableIDs(-5 * 60 * 60 * 1000);
   SimpleTimeZone pdt = new SimpleTimeZone(-5 * 60 * 60 * 1000, ids[0]);
    Calendar calendar = new GregorianCalendar(pdt);
 if(funcPressed == false){
  t.start(); // Start the timer
     funcPressed = true;
  mem.setEnabled(false);
 }
    else{ // changed mainDisplay to tuner view
      t.stop(); // Stop the timer
  mainDisplay.setText(""+frequency);
  funcPressed = false;
  mem.setEnabled(true);
 }
 }
}

//===========================MOUSE LISTENER===============================================

  public void mousePressed(MouseEvent e) {
  	if(e.getSource() == volUp && !numVolLbl.getText().equals("100"))
 {
 pressed = 1;
 
 }

//===============================VOLUME ADJUSTING DOWN==================================


 if(e.getSource() == volDown && !numVolLbl.getText().equals("0"))
 {
 pressed = 2;
 
 }
 
    System.out.println("Mouse pressed;");
  }

  public void mouseReleased(MouseEvent e) {
    pressed = 0;
    System.out.println("Mouse released;");
  }

  public void mouseEntered(MouseEvent e) {
    System.out.println("Mouse entered");
  }

  public void mouseExited(MouseEvent e) {
    System.out.println("Mouse exited");
  }

  public void mouseClicked(MouseEvent e) {
    System.out.println("Mouse clicked ");
    }
    public void increment()
    {
    if(pressed==1)
    {
 	numVolLbl.setText(""+ ++numVol); //increment volume
 if(numVolLbl.getText().equals("100")){
  volUp.setEnabled(false);
 }
 if(!numVolLbl.getText().equals("0")){ // disables button when limit reached
  volDown.setEnabled(true);
 }
    }
    if(pressed==2)
    {
    	numVolLbl.setText(""+ --numVol); //decrement volume
 if(numVolLbl.getText().equals("0")){
  volDown.setEnabled(false);
 }
 if(!numVolLbl.getText().equals("100")){ // disables button when limit reached
  volUp.setEnabled(true);
    }
    }
}}
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Nov 26th, 2004, 1:31 PM   #5
T3FLoN
Newbie
 
Join Date: Nov 2004
Posts: 21
Rep Power: 0 T3FLoN is on a distinguished road
heh thanx for the input, i just have to make a minor adjustment to make it move a little faster. right now i can click faster then it will move lol
but seriously thanx it helped a lot.
__________________
<span style='font-family:Courier'><span style='font-size:12pt;line-height:100%'><span style='color:orange'>☼☼☼ Just kill em all, and let God sort em out. ☼☼☼</span></span></span>
T3FLoN is offline   Reply With Quote
Old Nov 26th, 2004, 1:59 PM   #6
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Glad I could help.
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:22 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC