calculator

Keyboard Input with swing Java

ε祈祈猫儿з 提交于 2019-12-01 21:38:12
I am working a calculator using java swing and I want to be able to enter the numbers and operations via keyboard. I can't seem to get it working. import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Calculator extends JFrame implements ActionListener { JPanel[] row = new JPanel[6]; JButton[] button = new JButton[23]; JMenuBar menubar = new JMenuBar(); JMenu file = new JMenu("File"); JMenuItem clear = new JMenuItem("Clear"); JMenuItem exit = new JMenuItem("Exit"); String[] buttonString = {"7", "8", "9", "+", "4", "5", "6", "-", "1", "2", "3", "*", ".", "/", "C", "√",

How to transfer a value from one JLabel to another?

試著忘記壹切 提交于 2019-12-01 09:13:46
I have this calculator working, but I can't figure out how to get the value in the resultpane to the first textbox when you click the "finish" button. I'm new to Java. I've tried doing it, but I kept getting an error. import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.text.NumberFormat; import javax.swing.AbstractAction; import static javax.swing.Action.NAME; import javax.swing.JButton; import

WooCommerce Shipping Calculator (shipping-calculator.php) - PHP Override - Zip Code Only

我与影子孤独终老i 提交于 2019-12-01 06:47:32
问题 In need of some suggestions here. I'm attempting to edit my shipping calculator (not checkout calculator as based on https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/) I'm going through the code and I'm unable to replicate what I'm trying to accomplish as seen here: I just want to hide the State & Country options and make it so you can only enter a zip code. I've tried the obvious like hiding it in the CSS style sheet/override just making

about layouts in simple calculator

北慕城南 提交于 2019-12-01 06:46:05
hi there i am trying to make a calculator with coding sizes,layouts etc. by myself (trying to not use NetBeans and it is not a homework). but i am facing with a problem about empty spaces. i have a TextArea and Buttons but as you can see below i cant handle this space problem. here is my code, import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.JTextArea; public class calculator extends JFrame { public

How to transfer a value from one JLabel to another?

眉间皱痕 提交于 2019-12-01 06:37:31
问题 I have this calculator working, but I can't figure out how to get the value in the resultpane to the first textbox when you click the "finish" button. I'm new to Java. I've tried doing it, but I kept getting an error. import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.text.NumberFormat;

about layouts in simple calculator

空扰寡人 提交于 2019-12-01 04:11:46
问题 hi there i am trying to make a calculator with coding sizes,layouts etc. by myself (trying to not use NetBeans and it is not a homework). but i am facing with a problem about empty spaces. i have a TextArea and Buttons but as you can see below i cant handle this space problem. here is my code, import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import

How do I compute an array (or string) of numbers and mathematical operators

眉间皱痕 提交于 2019-12-01 01:03:02
I am making a calculator and pushing/saving all the numbers and operators clicked to an array and a string. I want to know which approach is the best in this case . Making a string or an array from the input OR a better approach I can't think of. I want to compute the array or string. The string is giving wrong answers and I don't have a clue on how I can compute the array. The demo calculator is below. $(document).ready(function(){ var inputArr = []; var inputStr = ''; $('span').click(function(){ $('#input').append($(this).text()); //push to inputArr inputArr.push($(this).text()); //add to

C++ simple operations (+,-,/,*) evaluation class

帅比萌擦擦* 提交于 2019-11-30 14:07:51
I am looking for a C++ class I can incorporate into a project I am working on. the functionality I need is evaluation of string operations to numerical form: for example "2 + 3*7" should evaluate to 23. I do realize what I am asking is a kind of an interpreter, and that there are tools to build them, by my background in CS is very poor so I would appreciate if you can point me to a ready made class . This should do exactly what you want. You can test it live at: http://www.wowpanda.net/calc It uses Reverse Polish Notation and supports: Operator precedence (5 + 5 * 5 = 30 not 50) Parens ((5 + 5

Open Windows' Calculator in my C# Win Application?

*爱你&永不变心* 提交于 2019-11-30 13:24:50
I know I can open Windows Calculator with the following code : System.Diagnostics.Process.Start("calc"); But I wanna open it in my C# Win Application, i.e : I don't want to open it in the independent window, I wanna open it in my window. How can I do it ? You cannot embed another application into your form. However, you can move the calculator window on top of your form and set your form as its parent. This might accomplish the visual effect that you're looking for. You might check into the SetParent API function. For example: System.Diagnostics.Process p = System.Diagnostics.Process.Start(

Simple Java calculator

删除回忆录丶 提交于 2019-11-30 09:50:03
问题 Firstly this is not a homework question. I am practicing my knowledge on java. I figured a good way to do this is to write a simple program without help. Unfortunately, my compiler is telling me errors I don't know how to fix. Without changing much logic and code, could someone kindly point out where some of my errors are? Thanks import java.lang.*; import java.util.*; public class Calculator { private int solution; private int x; private int y; private char operators; public Calculator() {