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)
My program has a MainFrame(extends JFrame)class and BasePanel(extends JPanel) class,and many other panels.I had used Images with JLabel in BasePanel.My current panel in MainFrame is BasePanel.I had used MouseListener so that when I click on any of the label it should show Other panel in same MainFrame and hide the BasePanel.But I am getting some problem with that.When I click on the Label,It hides the BasePanel but do not show the new Panel(Dictionary Panel in my code). In short when label is clicked I want to make DictionaryPanel visible and BasePanel invisible,both in MainFrame. I am using the following code on Label:
//constructor of BasePanel class public BasePanel() { dict=new Dictionary(); mf=new MainFrame(); dictLabel.addMouseListener(new MouseListener() { public void mouseReleased(MouseEvent arg0) {
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.
I've installed the Java JDK onto my Windows 8 laptop and the first thing I need to do is run the compiler from the Command Prompt. The first prompt I enter is C:java -version. This worked fine, however when I try to enter the next prompt C:javac -version, I am getting the following screen and messages:
Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved.
C:UsersMary>java -version java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
C:UsersMary>javac -version 'javac' is not recognized as an internal or external command,
operable program or batch file.
I have entered the path into the environment variables area within my control panel. Not too sure why the first prompt works, but the second doesn't...
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);
I was following a tutorial on how to make a game when i suddenly got an error concerning moving tiles. i get this error when i tried to use a and d to move:
Exception in thread "Display" java.lang.ArrayIndexOutOfBoundsException: 48600 at com.cherno.graphics.Screen.render(Screen.java:44) at com.cherno.Game.render(Game.java:124) at com.cherno.Game.run(Game.java:87) at java.lang.Thread.run(Unknown Source)
I do not get the error while using w or s but the tiles are still not moving when pressing them.
When does an internal cast actually happen? I am aware that compound assignment operator do an internal cast. Does it happen in Assignment 1?Assignment 2?Assignment 3?Assignment 4?
Java Code:
public class Parser{ public static void main( String[] args){ byte b=1; short s=1; int i=1; s=b;//Assignment 1 s<<=b;//Assignment 2 b<<=s;//Assignment 3 s +=i;//Assignment 4 } } mh_sh_highlight_all('java');
I am just learning java now i have a problem where i have to run a test order on my internalOrder class from the orderTester class and i,m not sure how to do this ?
This is the code i have for my order class:
public static void testCase8(){ orders ords = new orders ("Pen", 8, -0.5); System.out.println("Test Case 8:" + " " + ords.getOrderDetails());
[Code] ....
This is the code for my Internal class
public final static double DISCOUNT = 0.4; public InternalOrder(String productName,int quantity ){ super(productName, quantity,DISCOUNT); } public void printInternalReport(){ System.out.println("Printing internal report ..."); }
Now my orderTest class is passed though orders class if you need that code i will put it up...
I have a problem where i have to run a test order on my internalOrder class from the orderTester class and I am not sure how to do this. This is the code i have for my orderTester class:
public static void testCase8(){ orders ords = new orders ("Pen", 8, -0.5); System.out.println("Test Case 8:" + " " + ords.getOrderDetails());
[Code] ....
this is the code for my Internal class
public InternalOrder(String productName,int quantity ){ super(productName, quantity,DISCOUNT); } public void printInternalReport(){ System.out.println("Printing internal report ..."); }
Now my orderTest class is passed though orders class and intrenalOrder class if you need that code i will put it up.
I am attempting to make a CoalescedHashMap<K, V> with internal chaining. It isn't a hard concept, but it needs to extend AbstractSet and implement Map<K, V>.
Map requires a remove method that returns a V(value). AbstractSet extends Collection, which requires a remove method that returns a boolean value. It gives a syntax error either way it is done. This is a standard homework assignment for a junior level class, so there must be some way to deal with this. It is annoying as we do not need to implement the remove method, it just throws and exception.
I'm deploying Java 8 update 40 to my users and want to know if there's a way to manage sites that prompt the user with warnings about untrusted and unsigned applets?
i'm using the exception.sites file to manage applicable prompts/warnings for our internal sites, but doesn't look like the exception list works for untrusted and unsigned.
is there a way to manage these from an all users level, particularly with a deployment (ie, SCCM)?
I have a design scenario here which is quite interesting and complex. I have a Java class structure as follows,
class A { class B; innerClass B { List<class C> listofC; innerClass C { String attribute1; String attribute2; // Their getter setters } } }
So I have this as an API. Now my challenge is that I need to add one more property to inner class C. i.e attribute3 in innerClass C. I need to do this without disturbing the code in class A by extending these classes or writing a new wrapper, so I can use class C with new properties .
I hope this should be achievable through any design pattern either at runtime or design time.
So I want to know how in Java you can pass a unkown type into a method (type can be an int, double, or a user defined object) and return that unkown type.
example of what I want: Java Code: public (unknowntype)[] method2 ((unknowntype)[]) //Process Data //unknowntype.process(); return (unknowntype); } mh_sh_highlight_all('java');
I know in C you can use void pointers and in c++ we have templates but I do not know how java handles this. Also I want to know if it is possible to call a method in the unknowntype.
I'm a independent IT contractor. On 2 systems this week I've experienced an issue when attempting to download JAVA the file is of an unknown type in IE. See attached. Alternative browsers on the same machine function properly.
I am new to threads, This is a project about 2048 game to be more accurate, and i want this project to run in this thread that i make in main...
My main:
public class Execute { public static void main(String[] args){ Display d = new Display(); Shell s = new Shell(d); Model m = new Game2048Model(); View ui = new Game2048View(m.getBoardArr(),d,s);
[Code] ....
And the error is:
Exception in thread "Thread-0" org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(Unknown Source) at org.eclipse.swt.SWT.error(Unknown Source) at org.eclipse.swt.SWT.error(Unknown Source) at org.eclipse.swt.widgets.Display.error(Unknown Source) at org.eclipse.swt.widgets.Display.checkDevice(Unknown Source) at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source) at view.Game2048View.run(Game2048View.java:55) //problem at Run at java.lang.Thread.run(Unknown Source)
import java.util.*; public class CommonElements { private int comparisons; // number of comparisons made private Comparable[] arrayToSearch; // current array being traversed private Comparable[] commonElements = new Comparable[10]; private int arrayPosition = 0; //keeps track of what index to add an element to common at
[Code] ...
I have trying to get this down to the bar minimum. I am trying to cast the desired object array to a array of comparable. This is all required by the assignment.
I am getting a runtime error that I can not perform the desired cast. What do I need to provide the compiler in order to allow for this casting. I can not change the signature of the method however nothing about the class has been specified do I need to implement comparable? Also I don not now what the client is passing so how would I write a generic compareTo method to compare object of unknown types.
I am having some issues with errors. Here is my code...
import java.io.*; import java.util.Scanner; public class StormChaser { public static void main(String[] args) { // Constants final int MAX_STORMS = 319;
[Code] .....
I am having issues with these error messages.... I have tried a couple of different things with each error but haven't been able to figure it out.
Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '1' at java.util.Formatter.checkText(Unknown Source) at java.util.Formatter.parse(Unknown Source) at java.util.Formatter.format(Unknown Source) at java.util.Formatter.format(Unknown Source) at java.lang.String.format(Unknown Source) at Storm.toString(Storm.java:98) at StormChaser.DisplayStorms(StormChaser.java:141) at StormChaser.main(StormChaser.java:53)