Headless Exception in Java
Hello, I am learning java programming language and while learning java programming I have come across a exception which I have not heard yet. It is a Headless Exception in java. I am not having details about it. If anyone from you are having information about the Headless Exception in java then please provide information about it to me.
Re: Headless Exception in Java
The Headless Exception in java is a public class which extends UnsupportedOperationException. This type of exception will be thrown when code that is dependent on a keyboard, display, or mouse is called in an environment that does not support a keyboard, display, or mouse. I am also not having more information about it. But, from this you will able to know the some details about it.
Re: Headless Exception in Java
Headless Exception is a class in java and it provides you a method as public String getMessage(). It is having description which is copied from class: Throwable. This will return the whole information about the message string of this throwable. This method will override the getMessage in class Throwable. And when this method will get executed you will get the returning value of the string message of the Throwable instance.
Re: Headless Exception in Java
Hey, while creating a look and feel for my project, I have got this Headless Exception in Java. It will be provide you exact overview of how the structure of headless exception is exist.
Quote:
at sun.java2d.HeadlessGraphicsEnvironment.getDefaultS creenDevice(null:-2)
at com.sun.java.swing.plaf.windows.XPStyle.getImage(n ull:-2)
at com.sun.java.swing.plaf.windows.XPStyle.access$300 (null:-2)
at com.sun.java.swing.plaf.windows.XPStyle$Skin.<init >(null:-2)
at com.sun.java.swing.plaf.windows.XPStyle$Skin.<init >(null:-2)
at com.sun.java.swing.plaf.windows.XPStyle.getSkin(nu ll:-2)
at com.sun.java.swing.plaf.windows.WindowsTreeUI$Expa ndedIcon.<init>(null:-2)
at com.sun.java.swing.plaf.windows.WindowsTreeUI$Expa ndedIcon.createExpandedIcon(null:-2)
at com.sun.java.swing.plaf.windows.WindowsLookAndFeel .initComponentDefaults(null:-2)
at javax.swing.plaf.basic.BasicLookAndFeel.getDefault s(null:-2)
at javax.swing.UIManager.setLookAndFeel(null:-2)
at javax.swing.UIManager.setLookAndFeel(null:-2)
Re: Headless Exception in Java
Hey, if you want to get the Headless Exception in Java then you need to use the code below. I have got it while working on this code:
Code:
image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
graphic = image.createGraphics();
graphic.setColor(Color.white);
graphic.fillRect(0, 0, size.width, size.height);
component.setBounds(0, 0, size.width, size.height);
component.paint(graphic);
Re: Headless Exception in Java
Hey, if you make use of the book below then you will able to get the solution for your problem:
- Java Language Specification
- Java Native Interface
- Core Servlets and JavaServer Pages
- Thinking in Java - Bruce Eckel's renowned book
- Advanced Programming for the Java 2 Platform
- A Java GUI Programmer's Primer