Hi All
I have written a small swing program which is working perfectly in Windows.When i try to run the same program in unix its giving the following exception.
Exception in
thread "main" java.lang.InternalError: Can't connect to X11 window
server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:5
4)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:115)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvi
ronment.java:53)
at java.awt.Window.<init>(Window.java:183)
at java.awt.Frame.<init>(Frame.java:310)
at java.awt.Frame.<init>(Frame.java:289)
at javax.swing.JFrame.<init>(JFrame.java:167)
at LabelDemo.<init>(LabelDemo.java:9)
at LabelDemo.main(LabelDemo.java:45)
Can you please help me.
i am thinking some problem with look and feel but not sure.
Plase help me.
Here is my code
import java.awt.*;
import javax.swing.*;
class LabelDemo
extends JFrame
{
public LabelDemo()
{
super("JLabel Demo");
setSize(600, 100);
JPanel content = (JPanel) getContentPane();
content.setLayout(new GridLayout(1, 4, 4, 4));
JLabel label = new JLabel();
label.setText("JLabel");
label.setBackground(Color.white);
content.add(label);
label = new JLabel("JLabel",
SwingConstants.CENTER);
label.setOpaque(true);
label.setBackground(Color.white);
content.add(label);
label = new JLabel("JLabel");
label.setFont(new Font("Helvetica", Font.BOLD, 18));
label.setOpaque(true);
label.setBackground(Color.white);
content.add(label);
ImageIcon image = new ImageIcon("flight.gif");
label = new JLabel("JLabel", image,
SwingConstants.RIGHT);
label.setVerticalTextPosition(SwingConstants.TOP);
label.setOpaque(true);
label.setBackground(Color.white);
content.add(label);
setVisible(true);
}
public static void main(
String args[])
{
new LabelDemo();
}
}
Regards
Kiran