1 Reply Latest reply: Jul 30, 2014 4:14 AM by TPD-Opitz RSS

    unable to full screen swing form on fedora

    e9afb9a0-28d1-444a-a2dd-122cc55aae28

      Hi,

       

      I 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();

             

          }

       

      }