I am trying to use a JFrame to open up extra windows that will prompt the user the Log In or Out, but I am getting an error with one of my variables that writes to Excel. There is something wrong with the variable "sheet" contained in the "while(i <= 4)"
private void createLabel(WritableSheet sheet) throws WriteException { WritableFont times10pt = new WritableFont(WritableFont.TIMES, 10); times = new WritableCellFormat(times10pt); times.setWrap(true); WritableFont times10ptBoldUnderline = new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD, false, UnderlineStyle.SINGLE);
int x = 10; do{ System.out.print("value of x : " + x ); x++; System.out.print(""); }while( x + x == 22 );
When i put x+x==22 than it gives 2 values of x which are 10 and 11, they are wrong but when i put any other value like x+x==24 it just shows 1 value which is 10. I am not able to understand what mistake is there. I have been searching it for past whole month but didn't got any reason.
My program compiles and runs ok how ever when i open my Jinternal frame and click on one of the JLabels i get a error on the Cmd ther error reads as follows
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at JLabelAssignment.mouseClicked(JLabelAssignment.jav a:429) at java.awt.Component.processMouseEvent(Component.jav a:6508) at javax.swing.JComponent.processMouseEvent(JComponen t.java:3320)
import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.event.KeyEvent; public class Racquet { private static final int WIDTH = 60; private static final int HEIGHT = 20;
[code]....
The problem arises at the portion of the code that says
private int Y = game.getHeight() - 70;
I am not actually getting any compiler errors, but when I try to run the program, the command prompt pops up with this message:
Exception in thread "main" java.lang.NullPointerException at Racquet.<init>(Racquet.java:19) at Game.<init>(Game.java:10) at Game.main(game.java:58)
What I want to do is make it so a GUI object that I created moves with the screen when I change the height. If I change it to private int Y = 330; the program works just fine.
I would like to pass a variable I have in my main to my JFrame. In my main I calculate which pictures I should show in my JFrame. Is it possible to make objects of these pictures in my main class and use them in my JFrame? something like my code below.
public class JFrameTesting { public static void main(String[] args) { Image ImageVariable = Toolkit.getDefaultToolkit().getImage("C:1.jpg"); MyJFrame f = new MyJFrame(); f.setTitle("Drawing Graphics in Frames");
I have one question that suppose I am designing a Swing applications and I am using JFrame as Top level container.
So what is best
1)first Extends that class like
public class A Extends JFrame { //Do all stuff with Top Level container with gui }
2)Or design like this from this source
[URL] ....
package components; import java.awt.*; import java.awt.event.*; import javax.swing.*; /* TopLevelDemo.java requires no other files. */ public class TopLevelDemo { /** * Create the GUI and show it. For thread safety, this method should be invoked from the event-dispatching thread. */ private static void createAndShowGUI() { //Create and set up the window.
I am creating 2 different java codes for encryption and decryption separately based on RSA algorithm. The codes also involve swings for GUI. The problem with these codes are that my string is getting encrypted but after decrypting it,i do not get the string rather i get string of random numbers and alphabets. I am posting both the codes.
Encryption code:
import java.math.BigInteger; import java.util.Random; import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class cipher implements ActionListener
[Code] ....
Now the decryption code
import java.math.BigInteger; import java.util.Random; import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class decipher implements ActionListener
[Code] ....
The screenshots for respective codes are as attachments ....
import javax.swing.JFrame; public class groupingTest { public static void main (String[] args) { groupWindow test = new groupWindow();
[Code]....
At the start of the groupWindow it turns yellow and it says "The serializable class groupWindow does not declare a static final serialVersionUID field of type long".
Right so I have my ItemsPage Jframe Class and I'm trying to pass my TotalPrice variable to my CashPay so I can calculate the change. CashPrice runs and works but when I try run ItemsPage it does nothing I don't even get errors. I tried to remove that small section of trying to pass the variable to CashPay and it worked perfectly so I 100% know that's the problem. This section "public ItemsPage() { Pounds = ""; //super();
Scanner sc = new Scanner(System.in); CashPay sendTotalPrice = new CashPay(); //System.out.println("Enter your amount"); TotalPrice = sc.nextDouble(); sendTotalPrice.printTotalPrice(TotalPrice); " Here is complete code for both classes, I'm using GUI builder.
I am making a simple battleship program, you have the menu and click Start to get the board with the bombs (4 buttons as of now) Each button has either a bomb or a defualtbutton. I created my button so it can't be unselected. The problem is I have the button in a Class.java and I want that to close in a period of time. What do you recommend using?
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package battleship; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.GridBagLayout;
[code]....
I can call the clas in my main jFrame but I want to close the class after a certain time.
I am working with a program where I am required to use a JFrame in a child class. The only way that I know how to access a JFrame is to do, example (public class Example extends JFrame), but since it is already extending the parent class, I am kind of stuck. I do not think that you can extend two separate classes, so..... I am stuck.
What is the difference between extending JFrame in one class and simply constructing a new JFrame object in that same class? What benefits do I have with each solution, providing I want to use that class to create the GUI. Is it the same or are there differences rather than not having to reference to a new JFrame to be able to use its functions?
I am working on a program that simulates a bug moving along a horizontal line, My code works correctly when I test it in it's own class but when I tried testing my constructor and methods in a test class I received an error saying, "package stinkBug does not exist" on lines with my methods. However, stinkbug is not a package.
Java Code:
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */
In this code, I have to do a series of tasks to change a String using specialized codes that are inputted. The one that I am having trouble with is as follows:
MC-SLXD: Circulates the sub-string in position S with a length of L, rotate the string X characters over in the direction of D. All the arguments (S,L,X and D will be one character in length. The direction will be either L or R for Left or Right.Example: MC-332R/COMPUTER = COPUMTER.
I have to write the Insertion Sort Algorithm using Java codes and at the same time find the time of execution for different sizes of array, filled with random numbers. If I try to show the numbers inserted into the array randomly, they don't appear at the console.
import javax.swing.JOptionPane; public class Insertion { public static void main(String[]args){ int SizeArr = new Integer(JOptionPane.showInputDialog("Enter the size of teh array")).intValue(); int [] r= new int [SizeArr]; {for(int d=0; d<r.length; d++)
I'm working on a program using GUI. My problem is that I'm reaching **1000 Line** and this is stressful because all my code are in one file. I'm not liking this. So I research the internet about Inheritance. However, what I know about Inheritance that Inherit everything in the parent class. However, when I try to use a variables in the child class to override it in the parent class I can't for example let say that I have in the parent class something like this:
JButton getButton = new JButton("Enter");
Now when I go to the child class. I want to Inherit and use this variable so I can use the ActionListener on the getButton and override for the parent class, but it's not working.
This is my code:
public class H_Store extends JFrame { private String s ="Kinds: "; private JButton calculateButton; private JPanel mainPane; private JPanel getProfitPanel; private JTextField ground_M_QTextField;
[Code] ....
What I want to do exactly is to take the last code into another class or do something with it so I can use it in the Parent class, in other word any math calculation method or class I want them outside the Parent class. I mean this code :
private class CalcButtonListener implements ActionListener{ // vairbles for the ground Meat check box private double total_GM; private double weightPrice_1; private String stringQ; private String stringW; private String stringP;
I've been trying to pull data from another class file "Calculations.java" and have it be displayed in a TextField in "DataAnalyzerGUI.java". Here is how the hierarchy is broken down for my assignment:
I want to implement a kind of "container" in which to store objects (instances) of different types. Then with an iterator I'd call common methods. This is what I have in mind:
Where translate(x, y, z) is a method common for objects in Positionables which objects are of different types (Sphere, Box etc.).
Now I was thinking Positionables could be a List<Positionable> and Positionable is an abstract class and Sphere and Box extends from it. But I don't know how to propagate the call of translate() to the subclasses.
What are the best approaches for this matter? It would be perfect if I could make it so I could somehow use the "with" construction like in the example above.