JMenuItem mItem[] ={copy,paste};
for(int b=0;b<mItem.length;b++)
{
mItem[b].addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
String mItemCommand = e.getActionCommand();
JTextArea copypaste = new JTextArea(scr.getText());
if(mItemCommand=="Copy"){
copypaste.select(0,scr.getText().length());
copypaste.copy();
}
if(mItemCommand=="Paste"){
copypaste.setText("");
copypaste.paste();
String num =copypaste.getText();
try{double n=Double.parseDouble(num);
if(num.indexOf(".")!=-1)
isDecimal = false;
isFirstDigit = false;
if( n-((long)n)>0.0) // I just didn't understand codes starting from here
scr.setText(""+n);
else
scr.setText(""+((long)n));
if(n>=Long.MAX_VALUE || n<=Long.MIN_VALUE){
scr.setText("0");}
}catch(NumberFormatException ex){}
}
ali11 -1 Light Poster
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.