Swing/AWT/SWT :: ServiceUIFactory Always Return Null

Apr 11, 2015

ServiceUIFactory always returns null for MAIN_UIROLE

PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService();
ServiceUIFactory factory = defaultPrintService.getServiceUIFactory();

Object swingui = factory.getUI(ServiceUIFactory.MAIN_UIROLE, ServiceUIFactory.JCOMPONENT_UI);
System.out.println(swingui);

Object jdialogui = factory.getUI(ServiceUIFactory.MAIN_UIROLE, ServiceUIFactory.JDIALOG_UI);
System.out.println(jdialogui);

[code]...

View Replies


ADVERTISEMENT

JSF :: What Causes Backing Bean Return Null

Apr 6, 2015

I tried to create my first javaweb project. However when some action were being invoke I received an error. Here is what I did:

Person.javapackage org.javaeesample.entities;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;

[Code].....

When tried to run my project what happened were:

1. When i clicked the link from show.xhtml

<h:link value="#{p.name}" outcome="details">
<f:param name="pid" value="#{p.id}"/>
</h:link>

It output the page but without data being displayed.

but on the url it shows: [URL] .....

1. When i clicked 'Save' button in create.xhtml here is the error i received:

An Error Occurred:

View Replies View Related

Inheritance Super Variables - Fail To Return Null

Aug 13, 2014

I'm writing a simple program in which I have a super class Person, inherited by the subclasses Customer and Employee (they inherit the variables ID, name and surname).

Java Code:

public class Person {
int id;
String name;
String surname;
public Person () {

[Code] .....

However the problem is here: when I try to get the variables ID, name and surname through my main class, they fail to return (0,null,null). Why is this? I have get-Methods in my subclasses which should return the super variables, but they are not.

Java Code:

public String getUser() {
return username;
}

public String getName() {
return super.name;
} mh_sh_highlight_all('java');

View Replies View Related

Method Must Return Int Type - If Given Integer Is Strong Return A / If Not Return B

Sep 7, 2014

I want to use a method, which takes for example an int and also returns an integer. For example, if the the given integer is strong return a, if it is notstrong return b. How would you write that in a Code?

I want to use that in a more general way. I want to give a method mlong the value X of the type date and let it return an int. Type date consists of 3 int, one of them is the int month.

mlong should return an int depending on the X.moth. at the moment my code looks like this:

// File1:
public class date {
public int day;
public int month;
public int year;
}

// File 2:
public class monthlength {
public int mlong(date X) {
int t;
t = X.month;
if (t == 1 || t == 3 || t == 5 || t == 7 || t == 8 || t == 10 || t == 12)
{ return 31; }
if(t == 4 || t == 6 || t == 9 || t == 11)
{return 30;}
}
}

View Replies View Related

Swing/AWT/SWT :: Alternative To Null Layout

Aug 10, 2014

My IDE has a visual editor for creating Swing applications. The created application windows have no layout manager and use method "setBounds()" for placing Swing components on the application window. I have built an application that uses JInternalFrame. Each JInternalFrame is a separate and different "screen" for the user to interact with.

There are around 2,000 screens in the application and new screens are constantly being added as well as existing screens being modified. As a result, the top-level container - a JFrame - is a fixed size and is not resizable. I have now been asked to increase the size of the JFrame while maintaining the proportions of the screens.

Rather than manually editing the invocations of "setBounds()" on all the screens, any alternative way to achieve this? Also, is there a way to achieve this such that if, in future, the JFrame will again be resized, the screesn will automatically adjust?

View Replies View Related

Swing/AWT/SWT :: GetGraphics Method Returns Null

Aug 23, 2007

The getGraphics() method in my constructor is returning a nullPointerException and I can't figure out why. This class is extending a JPanel and I thought calling super() would fix it because it makes sense that the JPanel would initialize its graphics object in the constructor, but that didn't fix it. The line that produces the error is in bold. I've narrowed it down to the getGraphics() method is returning null, so the next line that calls the graphics object is actually the one that produces the error.

int leftMargin = 2, rightMargin = 2, topMargin = 2, bottomMargin = 2;
int lineSpacing = 1;
int currentX = leftMargin, currentY = topMargin;
Font defaultFont, customFont;
public HTMLFrame(){
super();

[Code] ....

print(String) is a method I made that draws lines of text on the graphics object, similar to System.out.println(String) in the command prompt.

View Replies View Related

Swing/AWT/SWT :: Null Pointer Exception When Retrieving Data From Table

Mar 31, 2015

I am trying to export data from a jtable to a pdf report but every time i try running the code it gives me this exception:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at GUI.QC_receiving_book.printButtonActionPerformed(QC_receiving_book.java:309)
at GUI.QC_receiving_book.access$600(QC_receiving_book.java:26)
at GUI.QC_receiving_book$7.actionPerformed(QC_receiving_book.java:165)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)

[Code] ....

I tried avoiding the null exception by using the if statement but it didn't work. The row I choose from the table is full meaning there are no empty attributes. and all the data are imported from a mysql database to the table as String so there can't be any casting errors.

This is the part of the source code with the problem and i will also post the printing method. I tried debugging the class and when stepping into the first if statement it opened the jTable.java file and pointed at the getSelectedRow() method and this sentence "variable information not available.source compiled without -g option"

private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {
if(samplesTable.getSelectedRow() >= 0){
int row = samplesTable.getSelectedRow();
System.out.println(row);
for(int x=0;x<samplesTable.getColumnCount();x++){
String value = samplesTable.getModel().getValueAt(row, x).toString();

[Code] ....

View Replies View Related

Swing/AWT/SWT :: How To Return 2 Values For A JDialog

May 10, 2014

All the samples I found use JOptionPane to return a single value. I am looking to return two values from two Text fields.

View Replies View Related

Null Pointer Access Variable Can Only Be Null At This Location

Apr 16, 2014

I'm getting an error on line 137 and all it is rsmd = rs.getMetaData();The error happens only after I press a JButton and it is

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExceptionat softwareDesign.createAccount.actionPerformed(createAccount.java:137)

There is a lot more to it but that has nothing to do with my code it's just the stuff with Eclipse anyway I want to know how do I fix this problem?

View Replies View Related

Swing/AWT/SWT :: Rotating Buffered Image And Then Return It

Mar 7, 2010

I wanted to write a method which gets a buffered image as parameter, rotates it 90 degrees clockwise around its top left corner, and then returns it. This method will be call from another method which then draws the rotated image on a rather large background which consists of many other images.

Here is the code I have so far:

public static BufferedImage rotate(BufferedImage img) {
int w = img.getWidth();
int h = img.getHeight();
BufferedImage newImage = new BufferedImage(width, height, img.getType());
Graphics2D g2 = newImage.createGraphics();
g2.rotate(Math.toRadians(90), w/2, h/2);
g2.drawImage(img,null,0,0);
return newImage;
}

This method does rotate an image 90 degrees, but when the calling method recieves this image and displays it on the bigger frame, parts of the rotated image is cut. I think because the frame holding the returned image is not big enough. I've tried playing around with the code a lot, chaging the sizes of different images, and trying AffineTransform features, but I have had no luck.

View Replies View Related

Why To Get Result Brand Null / Colour Null

Feb 28, 2015

public class Test {
public static void main(String[] args) {
Car c = new Car();
c.setInf("toyota", "red");
System.out.println("name: "+ c.brand + " colour: " + c.colour);

[code]....

Why do I get the result brand null, colour null? I know what null means but what am I missing here?

View Replies View Related

Swing/AWT/SWT :: How To Return Values From A JForm To The Main Window On Close

Jan 26, 2014

I am making a java swing program. I have a main window that opens a JForm window when the user clicks a menu option. Then I have a button on the JForm that closes the window on click. However, I would also somehow like to make the JForm return values to the main window (according to the states of the selector components) when it is closed. How would I go about this? Currently my jForm is a seperate class called "NewGame", and inside the menu item mouse clicked method, I have the following code:

//open new game jform window
NewGame newGameWindow = new NewGame();
newGameWindow.setVisible(true);
newGameWindow.setLocationRelativeTo(null); //center window

Is there something I can add here to get the object's values upon the window's close? Or is there a way I can add that into the button clicked method on the actual jForm?

View Replies View Related

How To Return Values In Object Return Type Function (method)

Apr 2, 2014

How do i take input values for TwoDPoint (which are objects) and return it back in numerical values also print them.

When i create an object in main method and pass values to my function of return type TwoDPoint,it gives error:- found int,int need TwoDPoiint,TwoDPoint.

// Here is what i tried to do:

Created class TwoDPoint that contains two fields x, y which are of type int. Defined another class TestTwoDPoint, where a main method is defined.In the main method created two TwoDPoint objects.

Then I modified the class TestTwoDPoint and add another function to it. This function takes two TwoDPoints as input and returns the TwoDPoint that is farthest from the point (0,0).

Then I added another function to TestTwoDPoint. This function takes two TwoDPoints as input and returns a new TwoDPoint whose x value is the sum of x values of the input TwoDPoint's and whose y value is the sum of the y values of the input TwoDPoint's.

class TwoDPoint {
int x = 2;
int y = 4;
}
class TestTwoDPoint {
public static void main(String args[]) {
TwoDPoint obj1 = new TwoDPoint();
System.out.println(obj1.x);
System.out.println(obj1.y);

[Code] ....

View Replies View Related

If Given Integer Is Even Return 1 / If Not Even Return 0

Sep 7, 2014

I want to use a method, which takes for example an int and also returns an integer. For example, if the the given integer is even return 1, if it is not even return 0. How would you write that in a Code?

I want to use that in a more general way. I want to give a method mlong the value X of the type date and let it return an int. Type date consists of 3 int, one of them is the int month.

mlong should return an int depending on the X.moth.

At the moment my code looks like this:

// File1:

public class date {
public int day;
public int month;
public int year;
}

// File 2:

public class monthlength {
public int mlong(date X) {
int t;
t = X.month;
if (t == 1 || t == 3 || t == 5 || t == 7 || t == 8 || t == 10 || t == 12)
{ return 31; }
if(t == 4 || t == 6 || t == 9 || t == 11)
{return 30;}
}
}

View Replies View Related

JSP :: How To Print Null Values In EL

Dec 18, 2014

The value is: ${object1.property1} If the value of the property is null, I want "null" to be printed, like this:

The value is: null But I get an empty string, like: The value is:

I know I can use a ternary operator, but isn't there a simpler/shorter solution? A function (like NVL() in SQL)?

The value is: ${empty object1.property1 ? "null" : object1.property1 }

Not only is this long, but the value expression is typed twice, which is a magnet for bugs.

View Replies View Related

Null Pointer Error

Oct 15, 2014

So I'm trying to add two numbers using a stack class I made myself. I have a main class with a main method in which I use three stacks on holds one number one holds the other and then I sum one digit at a time keeping in midn that there may be a carry before putting the result on a third stack.

My problem is I'm getting a null pointer error when it should be putting an integer into the top of my stack which is index 0, I've checked my code and can't see why it would be doing this.This is my main method in my main class

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

my input file looks like a single line of input stating the problem followed by two lines of input which need to be summed.this is the error I'm getting

Exception in thread "main" java.lang.NullPointerException
at StackClass.push(StackClass.java:38)
at CS25driver.main(CS25driver.java:55)

View Replies View Related

JPanel Appears To Be Null

Feb 23, 2014

I've a JPanel declared as a field in a JFrame:

public static javax.swing.JPanel pane;
I initialize it in a method (Well, Netbeans' GUI builder does. :P)
pane = new javax.swing.JPanel(){
@Override
public void paint(Graphics g){
g.setColor(Color.BLACK);
g.drawArc(8, 6, 15, 15, 0, 90); /* This works. The panel and frame are displayed, the arc is drawn, &c. */
}
};

it works and all; the arc is drawn.I want to draw on it dynamically by instantiating its Graphics (I call the "public Graphics getGraphics()" method.). This has worked for me before, taking a JPanel's Graphics and drawing with it through a different method than public void paint(Graphics g); But when I do, it comes up with a NullPointerException. WAIT! Don't go rambling on about initializing the variable because I've gotten past that NPE newbie's blockade.public static void render(Something s) { /*This is in a different file altogether. pane is public, static so I can access it from here. That's not the problem.*/

JPanel jp = Frame.pane;
Graphics g = jp.getGraphics();
g.fillRect(s.x, s.y, 4, 4);
}

Upon further investigation:
Exception in thread "main" java.lang.NullPointerException
at physics.Renderer.render(Renderer.java:30) <-- This line is "JPanel jp = Frame.pane;"
at physics.Renderer.renderall(Renderer.java:24) <--This line calls public static void render(Something s)
at physics.Updater.update(Updater.java:47) <--Renderer is just a tool used by the Updater. Sounds like a game loop, right?
at physics.Physics.main(Physics.java:31) <-- The game loop.

it says that Line 30, making jp and pointing it to pane itself is the problem.

Conclusion:
-The JPanel in the JFrame is created, initialized and overrides a parent method.
-The JPanel is not initialized, meaning that it is null. There is obviously a problem.

View Replies View Related

Why Is Method Returning Null

Sep 25, 2014

I am working on a project which manages an airport's airplanes and flights based on user input. The method printFlights() - lines 133-134 - is returning null and I can't figure out why. The method is supposed to print information about each flight. The logic is identical to the printPlanes() method which is working successfully.

View Replies View Related

Another Null Pointer Exception

Aug 14, 2014

It is supposed to create an array of random strings and sort them according to their HTML numbers. It creates the array correctly and even compiles correctly, but has a null pointer exception when it comes to the sorting. (I have cut out other parts of the program that were irrelevant).

the lines that produces the null Pointer Exception is line 24. if(array[i].charAt(0)>array[maxIndex].charAt(0))...and 53.stringSelectionSort(stringArray);

import java.util.Arrays;
import java.util.Random;
/**tests the array.sort() subroutine vs. a
'selection sort' that I will write. a random list
of integers is used first and times are recorded to
determine which one is more efficient. A random list
of strings is also tested.**/

[code]....

View Replies View Related

GetNextMailItem Keeps Returning Null

Jun 16, 2014

When I try to getNextMailItem,it keeps returning null.Why?

public class MailServer
{
// Storage for the arbitrary number of mail items to be stored
// on the server.
private HashMap<String,ArrayList<MailItem>> mailbox;
/**
* Construct a mail server.
*/
public MailServer()

[Code] .....

View Replies View Related

FileReader - Returning Null

Jan 12, 2014

I'm following a tutorial and I can't work out why the version that I have written is returning null when reading the text file...?

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class AppReadFileFileReader {
public static void main(String[] args) {
File file = new File("test.txt");
BufferedReader br = null;

[Code] ...

I can't see any difference in the code though, and the files being found in order for the null to appear... :?

the text file is within the Java project, and just has three lines :

line one
line two
line three

That's all it say..... But all my program returns is the work 'null'

View Replies View Related

Testing Double Null

May 2, 2014

how to execute a particular class. I've created a Kinematics class that will execute and calculate all the functions pertaining to kinematic equations. In the main class, I will have the user provide the data in JTextField. Now I need to test which JTextfields (variables) were left empty. I plan to use a number of if/else statements :

if(distanceI != null && distanceF != null)

The problem with this is that these variables are double and therefore cannot be tested as null. I read a few things about Double but I really don't see how I'm supposed convert each double variable to Double, is that even possible?

public class Kinematics {
double distanceI, distanceF, velocityI, velocityF,
velocityAverage, acceleration;
public Kinematics(){
//v2 = v1 + a*dt
if(distanceI != null && distanceF != null){
 
[code]...

View Replies View Related

When To Initialize A String Null And When Not

Sep 22, 2014

Trying to make me understand when to initialize a string 'null' and when not..??

View Replies View Related

Can A Null Value Be Concatenated With Existing String

Jan 16, 2014

static public String populateVehicleDetails(Vehicle vehicle){
String returnString = new String()
String existingString = "Chevy Uplander "
String nl = "
"
returnString.concat(existingString+nl).
concat("Color: "+ vehicle.color + nl)
  return returnString
}

In the case that vehicle.color is null what will happens? A null pointer error?

null will be concatenated to the string in vehicle.color place? or will not concatenate anything in the place of vehicle.color I'm asking that because I do not know if I have to check for null in each property of vehicle that I must concatenate (there are a lot of properties in the Vehicle object and some may not been set (they will return null).

View Replies View Related

If Statement Not Running When ResultSet Is Null

Feb 24, 2015

The below method shows that a JOptionPane should display when the result is null, meaning it has not found what I was trying to look for. However only the if statement that finds the query runs:

public void find(Person person) {
String query = "SELECT * from employee WHERE last LIKE'" + lastName
+ "'";
try {
statement = connection.createStatement();
resultSet = statement.executeQuery(query);
 
[Code] ....

View Replies View Related

What Is The Length Of A Null Array Object

Feb 21, 2014

I tried the following and it gives me null pointer exception. I just want to verify if what is the actual value of a length of an array?

Object [] obj = null;
System.out.println("length:" + obj.length);

View Replies View Related







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