Why Cannot Change Size Of TextField In Java For Calculator Application

Jan 13, 2014

package name;swing library found in javax called to use the graphical contents.

import javax.swing.*;
//creating the contents for the calculator
public class calc {
JButton btn1= new JButton("1 ");
JButton btn2= new JButton("2");
JButton btn3= new JButton("3");

[code]....

I have tried different sizes for the 'TextField' but when I change the size, the position changes instead of the size itself.

View Replies


ADVERTISEMENT

Java Calculator - Making Numbers To Stay At Textfield

Jul 12, 2014

How can I make the numbers to stay at the textfield of my calculator instead of disappear like when I type 1 then hit the + sign the number 1 disappears from the textfield I would like to have this (1+1) showing in the text field and also if try to press only + , * , - , / to show error.

this is my code

public class Calculator extends javax.swing.JFrame {
private double TEMP;
private double SolveTEMP;
Boolean addBool = false;
Boolean subBool = false;
Boolean divBool = false;
Boolean mulBool = false;
String display = "";

[Code] ....

View Replies View Related

Cannot Change Textfield Input

Jun 29, 2014

When in panel2 i type something in the search bar and then i move mouse cursor to panel1 and try to edit a JTextField input for example as in the picture 0.0 nothing happens but the mouse cursor is correctly show up in the JTextField.. What seems to solve the problem is to click anywhere outside of the application window.. but of course this is not a solution !

View Replies View Related

JavaFX 2.0 :: Unable To Change Textfield Value

Jun 8, 2014

I am having a small JavaFX program where I try to set a value to TextField. Below is the part of FXML file and highlighted is the Textfield ....

fxml file  
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="185.0" prefWidth="598.0">
          <children>
            <TextField fx:id="actiontarget" editable="true" layoutX="146.0" layoutY="73.0" prefWidth="198.0" text="" />
           
[Code] ...
 
I want to display a string value to that text field.

So, I am using that fxid (actiontarget)

But actiontarget.setText (pathofFile) is not working .
 
Nothing displays and no value sets for the Text field.
 
How can I set value in that text field through above code.

View Replies View Related

JRE :: Reduce Java Runtime Size When Bundled With Application

Mar 31, 2015

We are shipping in our company the JRE bundled with the client application in order to ensure the compatibility. But when upgrading from jre6 to jre8 the size increased by 50 MB!
 
Is there a reliable and secure way to reduce the footprint of the JRE? Are there "light distributions" or a list of libs/files that can be safely removed?

View Replies View Related

Swing/AWT/SWT :: Change Size Of Entire GUI?

Feb 4, 2015

I built a GUI and after testing it on various platforms I think I would like to make it bigger by a factor of 2.2 or so.

Is there an easy way to just enter the factor 2.2 and have the GUI change by that factor?

I have over 50 components in the GUI. Ideally each one would just enlarge by the factor including the fonts.

This was my first (and only so far) java program. I didn't know anything about layout managers. I used netbeans and it generated all the code.

View Replies View Related

Swing/AWT/SWT :: How To Change JFrame Size

Jan 14, 2015

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

[Code].....

View Replies View Related

Get ActionEvent When Change JFrame Size?

Apr 8, 2014

I wanted to make a program that would change the color of a circle when I click a button. The problem is that the circle also changes color when I manually change the size of the frame with my mouse. For some reason it trigers an ActionEvent, and i don't know why.

My code is the following:

Java Code: import java.awt.*;
import javax.swing.*;
public class MyFirstGui implements ActionListener {
JFrame frame;
public static void main(String[] args){

[code]....

View Replies View Related

How To Change Fonts And Font Size In Swing

Feb 10, 2014

So, I have a game. I would like to make a game where you press "start" and THEN it starts. Also, I want to have collision with triangles, not just squares. The way I handle collision right now is with if statements, if the object is within the other, game over.How would I do collision with triangles? Lastly, how do I set a high score? how to change fonts and font size in swing?

View Replies View Related

Calculator That Change Input Value Into Another Value

Nov 14, 2014

I am currently working on a small java programm. I use netbeans for it. And obviously I am new to java.

Basically its a calculator that change the input value into another value: like 10 € into whatever $ and same with Inch and Centimeters.

Therefore I need a second jDialog Form where i can change the factors for the calculator and start the calculator again.

Here is my problem: I can open the second Dialog but if I want to change the factor it doesn't change the value in the variable and the second calculator frame is with the old factors. It seems the double variable isn't working globally

I will add the files later when i find out how?

View Replies View Related

Swing/AWT/SWT :: Getting Icons To Change Size With Window Resize

Jan 19, 2014

I'm using a jpanel with an 8 by 8 grid layout of jlabels to which I'm adding images to represent a chess board. At first, I was using the ImageIcon class to initialize my icons, but as soon as I added these icons to the labels, the labels no longer changed size with the window (which I want to happen). URL...

So I copied in the class, and initialized a different set of icons using the stretch icon class (specifically, the method that allows you to initialize a stretch icon from a filename), however, when I use these stretch icons, the result is the same. Is something wrong with the class, or with my implimentation of it, and how would I fix this?

View Replies View Related

Swing/AWT/SWT :: Getting Icons To Change Size With Window Resize?

Jan 16, 2014

I'm using a jpanel with an 8 by 8 grid layout of jlabels to which I'm adding images to represent a chess board. At first, I was using the ImageIcon class to initialize my icons, but as soon as I added these icons to the labels, the labels no longer changed size with the window (which I want to happen). Someone suggested to me to use this custom stretch icon class, found here:

[URL] ....

So I copied in the class, and initialized a different set of icons using the stretch icon class (specifically, the method that allows you to initialize a stretch icon from a filename), however, when I use these stretch icons, the result is the same. Is something wrong with the class, or with my implementation of it, and how would I fix this?

View Replies View Related

Swing/AWT/SWT :: Getting Jlabel Icons To Change Size With Window Resize?

Feb 20, 2014

I'm trying to create a chess program in java swing, and for the board I'm using an 8 by 8 array of jlabels stuck inside a jpanel with a grid layout. I would like the board to change size when the window changes size, and the grid layout accomplishes this succesfully, until I add the actual icons to the jlabels. Then the board just stays a fixed size. Someone suggested I use their "Stretch Icon" class, found here:[URL] ...., so I tried initializing the icons using one of the constructors in the class (the one that takes an image name and a boolean value for whether or not you want the resisizing to be proportionate (to maintain the aspect ratio)). However, the same thing happened. The board appears, but it does not resisize. To attempt to fix this problem, I tried simplifying my code, reducing the program to two jlabels within the jpanel, for which I then tried to set the image in the same way. Here is my simplified code:

import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;

[Code] ....

I'm misusing the stretch icon class, or just generally what's going wrong/how to fix it?

View Replies View Related

How To Use Validation On Label Or Textfield In Java

Apr 28, 2014

How to use validation on a label or textfield in java.

I have a textfield and i want that only username with @ sign will be taken by the program or gives an error.or a textfield that can only take numeric values or whatever the developer wants to take from user..

View Replies View Related

EJB / EE :: Convert Standalone Java Thread Application Into Web Application In Tomcat

Nov 17, 2014

convert or move standalone java thread application into Tomcat server container for accessing its JNDI services? Also is it possible to schedule this thread application in Tomcat server? is it possible to keep this app in tomcat as web application and schedule in window's scheduler.

View Replies View Related

Want To Know Size Of Object In Java

Mar 11, 2015

class Father
{
public int a=5;
private int b=10;

[code]...

what is the size of obj from above code?

View Replies View Related

Increasing Java Heap Size

Nov 21, 2013

I am using a 64 bit Win 7 Pc with 64-bit JVM and we get the error: Java heap space. So we want to increase the Java heap size but not for one application but for every application or in general.

We tried with the java -xmx command but it didn't work...

We tried setting the system variable JAVA_OPTS but again it didn't work...

View Replies View Related

Calculator In Java

Oct 28, 2014

I can not this to work correctly.

public static void main(String[] args) {
FloatWrapper x1=new FloatWrapper(0);
FloatWrapper x2=new FloatWrapper(0);
do{
switch(menu()){
case 'a': if(dataInput(x1,x2)) add(x1,x2); break;
case 'b': if(dataInput(x1,x2)) subtract(x1,x2); break;

[code]....

View Replies View Related

Size Of Java Boolean Type In Memory

Jun 13, 2013

I searched everywhere but i didn't found anything about the real size of primitive boolean type used by java.

View Replies View Related

Make A Calculator Using Java GUI

Jul 29, 2014

I am trying to make a calculator using Java GUI. I've managed to make an ActionListener and add it to a button, but I've made an error in my code that I'm unsure of how to solve. Because of how I've written the code, only one number can be placed in the text field. For example, the an ActionListener for the three button on the calculator was added to the button, but no matter how many times the user presses the button, only one 3 will appear in the text field. The code is below:

import javax.swing.*;//import the packages needed for gui
import java.awt.*;
import java.awt.event.*;
public class Calculator {
public static void main(String[] args) {
JFrame window = new JFrame("Window");//makes a JFrame
window.setSize(300,350);

[code].....

As you can see, because the compiler forces the String variable to be final, so when the user presses the button, the code simply shows how a space character and three character would look like, because the String variable can't change. How do I write my code so that every time the user presses the button, a character is added to the text field?

View Replies View Related

Build A Calculator In Java?

Aug 28, 2014

I wanted to build a calculator in java but I have a problem I wanted to when I type "plus" , go to This IF but don't go

import java.util.Scanner;
public class Session {
static String amal;

[code]....

View Replies View Related

Grading Calculator In Java Program?

Sep 26, 2014

i have a similar problem but what i need to do is to detect an exused absent of which in my notepad is represented by 00 and 0 being an unexcused absent, anyway if a student has an excused absent example a quiz for that day will be deducted from the total quizzes example if i was the teacher and had 2 quizzes of 10 items each and she was absent in one of the quizes instead of let say her score was 9 on the first quiz it should go 9/10 and if it was an unexcused absent 9+0/20 anyway this is my java code and notepad example

import java.io.*;
import java.util.*;
import java.lang.*; 
public class GradingSystem {
public static void main (String[] args) throws FileNotFoundException

[code]...

View Replies View Related

GPA Calculator In Java Using Loops And Switch

Apr 25, 2015

I am trying to make GPA calculator. I decided to use only switch statement and make it as simple as possible. The point is to enter as many classes and students as user wants. I keep getting credit points 0 at the end and also text format is not good too. Here is the code.

import java.util.Scanner;
import java.io.*;
public class SwitchExercise{
public static void main(String[] args) {
String grade = "";
String grades="";
String coursename="";
String headingleft="COURSES";

[code]....

View Replies View Related

Java Calculator - Multiplication And Division

Apr 24, 2015

I am having problems with my code I have added the multiplication and division but they will not display also how can I correct any error when dividing by zero?

import java.awt.*;
import java.awt.event.*;
public class calculator2 extends java.applet.Applet implements ActionListener {
TextField txtTotal = new TextField("");
Button button[] = new Button[10];

[Code] .....

View Replies View Related

Java Calculator - Numbers Are Not Adding

Jul 12, 2014

So I was making a Java Calculator that only adds. The problem is that the numbers are not adding. I think it is because whatever has been clicked is not being saved to be added.

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;

[Code] .....

View Replies View Related

Simple Calculator Swing Java

Dec 13, 2014

I am a beginner with Java. I have never used SWING before but I have to use it now and I am clueless. I don't know if what I am doing is right.I need to create a simple calculator. My problem is getting the buttons the user clicks to appear in a text field. I know I haven't added the =/*- buttons yet.

I have left actionPerformed practically blank, what to put in ?

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* Created by IntelliJ IDEA.
* Date: 11/12/2014
* Changing Face Program.
*/
public class Calc extends JFrame implements ActionListener

[code]...

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved