Can any one suggest how to proceed with this.
On clicking on print button it should start printing on the console while the other button end is clicked it should stop printing.
When print button is clicked end button click is not recognised until process is print process is completed

Can any one suggest how to proceed with this.
On clicking on print button it should start printing on the console while the other button end is clicked it should stop printing.
When print button is clicked end button click is not recognised until process is print process is completed

start your own thread...

and for the button thing try this

enter = new JButton("Click here to calculate numeric palindrome.");
enter.setActionCommand("enter");
enter.addActionListener(this);

and for the action thing this

public void actionPerformed(ActionEvent e){
     if("enter".equals(e.getActionCommand())){
        //your code here
     }
}

hope this helps

don't you have to import:

import javax.swing.*; Class with JButtons and JLabels
import java.awt.event.*; Class that handels user clicks

These handle clicks and makes button/JLabel

It didnt work for me.
On click of PREV button it should pass command continuosly upto 1000 times or until end button is clicked.
When prev process going on, end button click is not recognising.
Here is the code...

public void run() {
				
		super.addActionListener(new ActionListener(){
			
			public void actionPerformed(ActionEvent e){
			while(true)
			{
				switch (command)
				{
				case DRCCommandButton.PREV: command=PREV;
																	EndButton.setEnabled(true);
											prev();
											break;
				case DRCCommandButton.END: command= END;
											end();
											return;
				default:drcConnection.sendDRCCode(command);
				}//switch
				command = PREV;
			}//while
			}});
	}
	
	public void prev(){
		super.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				System.out.println("new");
				if (command==4) end();
					
			}
		});
		
			System.out.println("PREV :"+prevcount++);
			
			try {
         		System.out.println("Sleep");
         		Thread.sleep(10000);
         	}
         	catch (InterruptedException e1) {
         		e1.printStackTrace();}
     	drcConnection.sendDRCCode(37);
			
		//prevcount=0;
	}
     	
     	
	public void end(){
		System.out.println("Ending...");
		prevcount=MAX;
		//thread.stop();
	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.