Ask Your Question
1

unable to full screen swing form on fedora 20

asked 2014-07-16 05:08:25 -0600

pradeep24 gravatar image

updated 2014-07-20 00:23:24 -0600

abadrinath gravatar image

Hi,

I am java developer and want to make swing form full screen even on taskbar on linux machine. But after trying so hard unable to achieve it. I am using fedora as operationg system. Below i am giving you my swing code. but whenever i run this file form comes up on the screen and waits for a second and it goes in background. I unable to understand why this is happening. so please help me to solve this problem.

i am using linux OS Fedora 64 bit.


import java.awt.Color; import java.awt.Font; import java.awt.GraphicsEnvironment; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException;

import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextArea; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException;

public class ThankYou {

JFrame f; 
JTextArea nameField;
JLabel lable;
String str;

public ThankYou() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, IOException {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    String mystr=Readxml();
    f=new JFrame(); 

    nameField = new JTextArea(str);//value of str is Thank You 
    nameField.setBounds(450,450,650,60); 
    nameField.setForeground(new Color(6,42,120));
    nameField.setFont(new Font("Caladea", Font.BOLD, 60));
    nameField.setOpaque(false);
    nameField.setEditable(false);

    BufferedImage image = ImageIO.read(new File("imageTMB.jpg"));
    lable=new JLabel(new ImageIcon(image));
    lable.setLayout(null );

    lable.add(nameField);
    f.add(lable);
    f.setResizable(false);
    f.setUndecorated(true);
    f.validate();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(f);
    f.setVisible(true);
}

public String Readxml()
{
    try{

        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
        Document doc = docBuilder.parse (new File("File.xml"));
        doc.getDocumentElement ().normalize ();
        NodeList listOfPersons = doc.getElementsByTagName("Format");

        Node FormatNode = listOfPersons.item(0);
        Element firstPersonElement = (Element)FormatNode;

        NodeList firstNameList = firstPersonElement.getElementsByTagName("ThankYou");
        Element firstNameElement = (Element)firstNameList.item(0);

        NodeList textFNList = firstNameElement.getChildNodes();
        str=((Node)textFNList.item(0)).getNodeValue().trim();



    }
    catch(SAXParseException err){
         System.out.println ("** Parsing error" + ", line " 
                 + err.getLineNumber () + ", uri " + err.getSystemId ());
            System.out.println(" " + err.getMessage ());

            }catch (SAXException e) {
            Exception x = e.getException ();
            ((x == null) ? e : x).printStackTrace ();

            }catch (Throwable t) {
            t.printStackTrace ();
            }


    return str;

}
public static void main(String[] args) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
    new ThankYou();

}

}

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-07-19 01:00:21 -0600

abadrinath gravatar image

I am pretty sure this is a bug with your code, or otherwise, a bug with Java. I have tried your code, and it does not work. This is not exactly relevent to Fedora, so I suggest you take this code to Stack Exchange or Linux Questions. They could provide a much better answer than most of us here :).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-07-16 05:08:25 -0600

Seen: 205 times

Last updated: Jul 19 '14