Upload
ajit-panada
View
3
Download
0
Embed Size (px)
Citation preview
1. Write a program on Swings for Scientific Calculator.
Sci_calcApp.java
package sci_calc;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
public class Sci_calcApp extends SingleFrameApplication {
@Override protected void startup() {
show(new Sci_calcView(this));
}
@Override protected void configureWindow(java.awt.Window root) {
}
public static Sci_calcApp getApplication() {
return Application.getInstance(Sci_calcApp.class);
}
public static void main(String[] args) {
launch(Sci_calcApp.class, args);
}
}
Sci_calcView.java
package sci_calc;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
public class Sci_calcView extends FrameView {
String op1,op2,opcode;
double oper2;
public Sci_calcView(SingleFrameApplication app) {
super(app);
initComponents();
ResourceMap resourceMap = getResourceMap();
int messageTimeout =
resourceMap.getInteger("StatusBar.messageTimeout");
messageTimer = new Timer(messageTimeout, new ActionListener() {
public void actionPerformed(ActionEvent e) {
statusMessageLabel.setText("");
}
});
messageTimer.setRepeats(false);
int busyAnimationRate =
resourceMap.getInteger("StatusBar.busyAnimationRate");
for (int i = 0; i < busyIcons.length; i++) {
busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i
+ "]");
}
busyIconTimer = new Timer(busyAnimationRate, new ActionListener()
{
public void actionPerformed(ActionEvent e) {
busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
}
});
idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
statusAnimationLabel.setIcon(idleIcon);
progressBar.setVisible(false);
mainPanel = new javax.swing.JPanel();
mainPanel.setName("mainPanel"); // NOI18N
jPanel1.setName("jPanel1"); // NOI18N
});
public static void main(String args[]){
}
}
}
Output: