I'm at the Image part of this chapter and I wrote/copied these 2 classes:
[URL]
The error:
Exception in thread "main" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(Unknown Source) at image.Board.<init>(Board.java:17) at image.Image.<init>(Image.java:10) at image.Image.main(Image.java:20)
I'm fairly certain the problem is the path in this piece of code:
ImageIcon ii = new ImageIcon(this.getClass().getResource("C:GebruikersKristofferworkspaceImagessrcimageNature.jpeg"));
I've done some research and found that I should place the image in the same folder as my .java files, which I did [URL] but the problem still persists.
I have tried to add a scroll bar line 28 - 31 and can't figure out why its not working. Its not even showing the scroll bar!
public class TheFrame extends JFrame { private static ThePanel canvas; private String deckImagesToUse; /** * The constructor creates a Frame ready to display the cards */ public TheFrame(String cardImgFile) {
I am trying to compare a ImageIcon in a button against another. The method which has the issue is checkMatrixValues() third from the bottom of this post. I did my best to make this post flow as I am looking at the issue, hope it is not confusing.
the view class creates a matrix of Mybuttons and Mybuttons extends JButton. I did this because I need Mybuttons to have fields within each button.
public class View extends Mybuttons{ private static final long serialVersionUID = 1L; JFrame frame; JPanel matrixPanel, optionsPanel; Mybuttons[][] matrixBtn;
[Code]...
MyButtons has a few values and methods in it but here is a peek at the fields. This post is concentrating on ImageIcon greenIcon and ImageIcon redIcon.
public class Mybuttons extends JButton { private static final long serialVersionUID = 1L; Boolean barrier,startNode,targetNode,visited; public ImageIcon greenIcon = new ImageIcon("green.png"); public ImageIcon redIcon = new ImageIcon("red.png"); private ImageIcon yellowIcon = new ImageIcon("yellow.png"); private ImageIcon resetIcon = new ImageIcon("null"); public int counter;
In the controller class one method checks to make sure there is one start and one end point by calling checkMartixValues when the enter button is pressed: (FYI greenIcon is start and redIcon is end)
if(e.getSource()==view.enterBtn){ for(int i=0;i<25;i++){ for(int j=0;j<25;j++){ //Validates matrix to see if there are more then one //red or green button pressed checkMartixValues(view.matrixBtn[i][j]);
[Code]...
When I do the following:
if(matrixBtn.getIcon()==view.matrixBtn.redIcon)
It runs but jumps to the else statement. Again it is saying redIcon is not a field yet I am able to access other fields from view.matrixBtn. I even tried:
if(matrixBtn.getIcon()==buttons.redIcon) //compiles but will skip to else statement too //remember the above if statement is in the same controller class which declares public class Controller { /*The view class holds the GUI and creates a matrix of MyButtons. *Each of MyButtons will be treated as a node in the Controller Class *Consider MyButtons as the Model in the MVC design * */ View view; Mybuttons buttons;
I have been assigned with a task to have a class which has the methods setImage and getImage. These methods are meant to set the ImageIcon by using the url taken from another class and the getImage method is meant to return the ImageIcon that was set before hand. The problem is that i'm not really familiar with ImageIcon so the code in both my methods is giving out errors and i just can't figure out why. Heres the code in the class that has the setImage and getImage methods:
public class Die implements DieInterface { private ImageIcon [] image = new ImageIcon[6]; //the number of images that would be stored in this array is 6 (six faces of the dice) ublic Die() { //This puts images into the images array(the different die faces) image = new ImageIcon[6];
[code]....
And this is where i call the methods (set and get methods) in the other class:
I am trying to do a program about a contact agenda, now, I have one JPanel that contains three sub panels (GridLayout(1,3)) where I have in the left the picture of the Contact, the middle one is not important, but the right one contains 4 JTextFields with information of the contact and one JCheckBox that indicates if the contact is a favorite or not. The thing is that I am only able to show the first contact, but I want to be able to scroll between the contacts with a Button that I have in another panel. I think I am actually scrolling among the contacts, but the panel with the information from the contact is not updating the information...
public class PanelInfoContacto extends JPanel{
// ----------------------------------------------------------------- // Constructores // ----------------------------------------------------------------- /** * Construye el panel. <br/> * @param contacto - es una referencia al contacto que muestra. contacto != null. */ public PanelInfoContacto(Contacto contacto){ setLayout(new GridLayout(1,3));
<%@ page language="java" isErrorPage="true" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Error</title> </head>
[code]...
I have put error.jsp and badpage.jsp file in public access folder that is web content in eclipsewhen I am running the code I am status code of 500 and not the errorpage.jsp message .
I'm doing a software Java GUI - JFrame form like this:
1. The user wants to click on a button that opens a bunch of images that will be displayed as thumbnail in the bottom of the JFrame . 2. Then the user wants to select/click one of the thumbnail and make appear the corresponding image in it's original size on above(center) of the JFrame.
For doing this I used 3 JPanel.
One contains a JButton that opens the jfilechoser dialog window, the second "panelPreview" is for putting the thumbnails created, and the third "panelGrande" is for the image in it's original size.
The firs part "1." is ok.
But in the second part : I got one error when I want to put the ImageIcon in to the JLabel with the further intent of displaying it.
lblBig(imgIcoVett[i]);
In this project I'm dealing with arrays of ImageIcons and JLabels, so it's a bit advanced level for me, so I'm not sure that I wrote right the part of the MouseListener too.
The error displayed by netbeans says "cannot find symbol symbol: method lbl (ImageIcon) local variables referenced from an inner class must be final or effectively final"
Here I attach the project I did with netbeans"AAAD Unlayout 2.zip", but if you just need the highlight of the code, here it is too:
I am working on a program to have a user input two positive integers and then finding the greatest common denominator between the two. My problem is, I don't know how to display the number (num2) that is returned after the method. Putting a simple System.out.println gives me the error "unreachable code".
import java.util.Scanner; public class **** { public static void main(String[] args)
I have a problem with one method for my assignment. This is the requirement for this method: "This method uses a loop to list all accounts contained in the Array, adding each account details to a String, before outputting to screen in the format specified in the screenshot below. Ensure that there are no out of bounds exceptions by checking if each array slot has an account object before adding its details to the output String. (arrayname[index] != null)"This is my code for this method:
public void listAllAccounts() { String allAccountsString = "List of all accounts: "; for(int i = 0; i < ACCOUNT_SPACES; i++) { //allAccountsString += accountArray[numAccounts]; if (accountArray[i] !=null) { allAccountsString += accountArray[i].toString() + " " ; } } JOptionPane.showMessageDialog(null, allAccountsString);
The problem is that the Message Dialog does not display the accounts I have already created. It just displays "List of all accounts: ";
I created a instance of a class AddItemView, inside StartUpMenuController. I then passed it into the class, the main method is below showing that as well. However when I do this:
else if(e.getSource()==menu.addBtn) { new addItem(); }
I get an error, little red line on the bottom of the text. I am testing the frame at the moment to make sure it is what I want before I move on to the Controller side of it. I just want to display it and go from there.
package mainMenu.Home.DataBase; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import addItemBtn.Home.DataBase.AddItemView; public class StartUpMenuController { StartUpMenu menu; AddItemView addItem;
[code]...
Not sure if this is the issue but the class I am making a new instance of is in a different package. I imported the package though.
I am trying to display the files stored in server using jsp. I used the code below to display. But for pdf it is asking to download (No option for open). For XLS, XLSX, DOCX, PPT and PPTX it is showing zip file to download. For type doc it is showing junk data.
<% String fileName=(String)request.getAttribute("fileName"); int loc = fileName.lastIndexOf("."); String fileName1 = fileName.substring(0, loc); String fileName2 = fileName.substring(loc + 1, fileName.length());
One of my official site is not disaplying the content in machine#1 IE10 browser.And the same site is showing data in another machine#2. I compared the both machines JRE and JDK settings but no difference found.
I'm learning about inheritance and part of my problem is to create an Order with methods, then an UpdateOrder where the total price is changed by adding four dollars to it, and then a main method displaying a few orders. I've copied all three below in order. My question is when I run the program it will display the totalprice() first for the second order followed by name, number, etc.what you override always displayed first regardless of the order you put them in? (The issue is at line 31 on the third code.)
import javax.swing.JOptionPane; public class Order { //superclass private String customerName; private int customerNumber; protected int quantityOrdered; protected double unitPrice; protected double totalPrice;
I need to display my calculations in a table format using loops.
//Imports import java.util.*; import java.text.*; public class YourLoanCalculator {
[code]....
The increments are correct, but I wanted them listed under the "Payment #:" column. I figure that if I do that, I can also correctly display the interest, principal, unpaid balance and total interest paid at that point, right?
As you can see instead of displaying the champion name it is displaying the memory location and I do not know how to fix it.
class Champions { String name; Champions [] weak = new Champions [3]; Champions [] strong = new Champions [3]; String [] items = new String [3]; public static void main (String [] args) {
1. Why, when I press "New" rapidly, will it skip painting shapes sometimes/adding to totcount.
2. How can I make it so that The box in the background(which is currently connected in the wrong way as I was getting an error when I connected it correctly) can be modifiably large. AKA, I want to draw a grid in the background that can be different sizes, depending on the values of a variable xsize and ysize.
3. What can I do to clean this up? All I want it to do is display the convex hull of the four points given in the int[][] displaypoints.