Quantcast

Java Swing and maximize window

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Java Swing and maximize window

Sergi Torrellas
Hi all,

I installed jikes (java compiler) and cacao (java runtime) in order to have java in my gumstix successfully.
I would like to have a swing application running in my gumstix with a swing frame. However, I cant have the window maximised on default. Here my code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Toolkit;

public class HelloWorldSwing {
    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame("HelloWorldSwing");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize( 200,100 );
    frame.setExtendedState( JFrame.MAXIMIZED_BOTH );

        //Add the ubiquitous "Hello World" label.
        JLabel label = new JLabel("Hello Worldddddddd");
    label.setSize(200,100);
        frame.getContentPane().add(label);

        //Display the window.
        frame.pack();
        frame.setVisible(true);

    // Get the size of the window
    Toolkit tk = Toolkit.getDefaultToolkit(); 
    int xSize = ((int) tk.getScreenSize().getWidth()); 
    int ySize = ((int) tk.getScreenSize().getHeight()); 
    System.out.println("Size of the window" + xSize + " " + ySize);

    }

    public static void main(String[] args) {
    System.out.println ( "-- Program Start --" );

        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    System.out.println ( "-- Program End --" );

    }
}

and here the result of the execution:

root@overo:~/javaTests/swing# bash -x compileAndRun.sh
+ javac HelloWorldSwing.java
+ java HelloWorldSwing
-- Program Start --
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:46: Clearlooks configuration option "menuitemstyle" is not supported and will be ignored.
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:47: Clearlooks configuration option "listviewitemstyle" is not supported and will be ignored.
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:48: Clearlooks configuration option "progressbarstyle" is not supported and will be ignored.
-- Program End --
Size of the window480 272

I have not many ideas about this. What about you?

Many thanks in advance,

Sergi

--
SERGI TORRELLAS SOCASTRO
eHealth AIL Coordinator
R+D Salut

M. 616.21.72.97

[hidden email]
skype:sergi.torrellas



BARCELONA DIGITAL CENTRE TECNOLÒGIC
R
oc Boronat 117, 5a planta, 08018 Barcelona 
Tel. <a href="tel:%2B34%2093%20553%2045%2040" value="+34935534540" target="_blank">+34 93 553 45 40 - Fax. <a href="tel:%2B34%2093%20553%2045%2041" value="+34935534541" target="_blank">+34 93 553 45 41 

www.bdigital.org



------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Java Swing and maximize window

Blaine Booher-2
This is likely a question better suited for the java (or gnome) guys.

Sincerely,
Blaine 



On Thu, Mar 1, 2012 at 10:21 AM, Sergi Torrellas <[hidden email]> wrote:
Hi all,

I installed jikes (java compiler) and cacao (java runtime) in order to have java in my gumstix successfully.
I would like to have a swing application running in my gumstix with a swing frame. However, I cant have the window maximised on default. Here my code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Toolkit;

public class HelloWorldSwing {
    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame("HelloWorldSwing");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize( 200,100 );
    frame.setExtendedState( JFrame.MAXIMIZED_BOTH );

        //Add the ubiquitous "Hello World" label.
        JLabel label = new JLabel("Hello Worldddddddd");
    label.setSize(200,100);
        frame.getContentPane().add(label);

        //Display the window.
        frame.pack();
        frame.setVisible(true);

    // Get the size of the window
    Toolkit tk = Toolkit.getDefaultToolkit(); 
    int xSize = ((int) tk.getScreenSize().getWidth()); 
    int ySize = ((int) tk.getScreenSize().getHeight()); 
    System.out.println("Size of the window" + xSize + " " + ySize);

    }

    public static void main(String[] args) {
    System.out.println ( "-- Program Start --" );

        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    System.out.println ( "-- Program End --" );

    }
}

and here the result of the execution:

root@overo:~/javaTests/swing# bash -x compileAndRun.sh
+ javac HelloWorldSwing.java
+ java HelloWorldSwing
-- Program Start --
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:46: Clearlooks configuration option "menuitemstyle" is not supported and will be ignored.
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:47: Clearlooks configuration option "listviewitemstyle" is not supported and will be ignored.
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:48: Clearlooks configuration option "progressbarstyle" is not supported and will be ignored.
-- Program End --
Size of the window480 272

I have not many ideas about this. What about you?

Many thanks in advance,

Sergi

--
SERGI TORRELLAS SOCASTRO
eHealth AIL Coordinator
R+D Salut

M. 616.21.72.97

[hidden email]
skype:sergi.torrellas



BARCELONA DIGITAL CENTRE TECNOLÒGIC
R
oc Boronat 117, 5a planta, 08018 Barcelona 
Tel. <a href="tel:%2B34%2093%20553%2045%2040" value="+34935534540" target="_blank">+34 93 553 45 40 - Fax. <a href="tel:%2B34%2093%20553%2045%2041" value="+34935534541" target="_blank">+34 93 553 45 41 

www.bdigital.org



------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users



------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Java Swing and maximize window

Mark Zieg
Hi Sergi,

You might be able to control this with X-Window settings.  For instance, under OpenBox, you can set some things like that by configuring some overrides in ~/.config/openbox/rc.xml:


-MZ

On Mar 1, 2012, at 10:27 AM, Blaine Booher wrote:

This is likely a question better suited for the java (or gnome) guys.

Sincerely,
Blaine 



On Thu, Mar 1, 2012 at 10:21 AM, Sergi Torrellas <[hidden email]> wrote:
Hi all,

I installed jikes (java compiler) and cacao (java runtime) in order to have java in my gumstix successfully.
I would like to have a swing application running in my gumstix with a swing frame. However, I cant have the window maximised on default. Here my code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Toolkit;

public class HelloWorldSwing {
    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame("HelloWorldSwing");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize( 200,100 );
    frame.setExtendedState( JFrame.MAXIMIZED_BOTH );

        //Add the ubiquitous "Hello World" label.
        JLabel label = new JLabel("Hello Worldddddddd");
    label.setSize(200,100);
        frame.getContentPane().add(label);

        //Display the window.
        frame.pack();
        frame.setVisible(true);

    // Get the size of the window
    Toolkit tk = Toolkit.getDefaultToolkit(); 
    int xSize = ((int) tk.getScreenSize().getWidth()); 
    int ySize = ((int) tk.getScreenSize().getHeight()); 
    System.out.println("Size of the window" + xSize + " " + ySize);

    }

    public static void main(String[] args) {
    System.out.println ( "-- Program Start --" );

        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    System.out.println ( "-- Program End --" );

    }
}

and here the result of the execution:

root@overo:~/javaTests/swing# bash -x compileAndRun.sh
+ javac HelloWorldSwing.java
+ java HelloWorldSwing
-- Program Start --
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:46: Clearlooks configuration option "menuitemstyle" is not supported and will be ignored.
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:47: Clearlooks configuration option "listviewitemstyle" is not supported and will be ignored.
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:48: Clearlooks configuration option "progressbarstyle" is not supported and will be ignored.
-- Program End --
Size of the window480 272

I have not many ideas about this. What about you?

Many thanks in advance,

Sergi

--
SERGI TORRELLAS SOCASTRO
eHealth AIL Coordinator
R+D Salut

M. 616.21.72.97

[hidden email]
<a href="skype:sergi.torrellas">skype:sergi.torrellas




BARCELONA DIGITAL CENTRE TECNOLÒGIC
R
oc Boronat 117, 5a planta, 08018 Barcelona 
Tel. <a href="tel:%2B34%2093%20553%2045%2040" value="&#43;34935534540" target="_blank"> +34 93 553 45 40 - Fax. <a href="tel:%2B34%2093%20553%2045%2041" value="&#43;34935534541" target="_blank"> +34 93 553 45 41 

www.bdigital.org



------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users

********************************************************

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. If you are not the addressee, any disclosure, reproduction,
copying, distribution, or other dissemination or use of this communication is
strictly prohibited. If you have received this transmission in
error please notify the sender immediately and then delete this e-mail.
E-mail transmission cannot be guaranteed to be secure or error free as
information could be intercepted, corrupted lost, destroyed, arrive late or
incomplete, or contain viruses.
The sender therefore does not accept liability for any errors or omissions
in the contents of this message which arise as a result of e-mail
transmission. If verification is required please request a hard copy
version.

********************************************************


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Java Swing and maximize window

Sergi Torrellas
Thanks all for your answers!

Sergi

2012/3/1 Mark Zieg <[hidden email]>
Hi Sergi,

You might be able to control this with X-Window settings.  For instance, under OpenBox, you can set some things like that by configuring some overrides in ~/.config/openbox/rc.xml:


-MZ

On Mar 1, 2012, at 10:27 AM, Blaine Booher wrote:

This is likely a question better suited for the java (or gnome) guys.

Sincerely,
Blaine 



On Thu, Mar 1, 2012 at 10:21 AM, Sergi Torrellas <[hidden email]> wrote:
Hi all,

I installed jikes (java compiler) and cacao (java runtime) in order to have java in my gumstix successfully.
I would like to have a swing application running in my gumstix with a swing frame. However, I cant have the window maximised on default. Here my code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Toolkit;

public class HelloWorldSwing {
    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     */
    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame("HelloWorldSwing");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize( 200,100 );
    frame.setExtendedState( JFrame.MAXIMIZED_BOTH );

        //Add the ubiquitous "Hello World" label.
        JLabel label = new JLabel("Hello Worldddddddd");
    label.setSize(200,100);
        frame.getContentPane().add(label);

        //Display the window.
        frame.pack();
        frame.setVisible(true);

    // Get the size of the window
    Toolkit tk = Toolkit.getDefaultToolkit(); 
    int xSize = ((int) tk.getScreenSize().getWidth()); 
    int ySize = ((int) tk.getScreenSize().getHeight()); 
    System.out.println("Size of the window" + xSize + " " + ySize);

    }

    public static void main(String[] args) {
    System.out.println ( "-- Program Start --" );

        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    System.out.println ( "-- Program End --" );

    }
}

and here the result of the execution:

root@overo:~/javaTests/swing# bash -x compileAndRun.sh
+ javac HelloWorldSwing.java
+ java HelloWorldSwing
-- Program Start --
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:46: Clearlooks configuration option "menuitemstyle" is not supported and will be ignored.
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:47: Clearlooks configuration option "listviewitemstyle" is not supported and will be ignored.
/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:48: Clearlooks configuration option "progressbarstyle" is not supported and will be ignored.
-- Program End --
Size of the window480 272

I have not many ideas about this. What about you?

Many thanks in advance,

Sergi

--
SERGI TORRELLAS SOCASTRO
eHealth AIL Coordinator
R+D Salut

M. 616.21.72.97

[hidden email]
skype:sergi.torrellas




BARCELONA DIGITAL CENTRE TECNOLÒGIC
R
oc Boronat 117, 5a planta, 08018 Barcelona 
Tel. <a href="tel:%2B34%2093%20553%2045%2040" value="+34935534540" target="_blank"> +34 93 553 45 40 - Fax. <a href="tel:%2B34%2093%20553%2045%2041" value="+34935534541" target="_blank"> +34 93 553 45 41 

www.bdigital.org



------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users

********************************************************

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. If you are not the addressee, any disclosure, reproduction,
copying, distribution, or other dissemination or use of this communication is
strictly prohibited. If you have received this transmission in
error please notify the sender immediately and then delete this e-mail.
E-mail transmission cannot be guaranteed to be secure or error free as
information could be intercepted, corrupted lost, destroyed, arrive late or
incomplete, or contain viruses.
The sender therefore does not accept liability for any errors or omissions
in the contents of this message which arise as a result of e-mail
transmission. If verification is required please request a hard copy
version.

********************************************************


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users




--
SERGI TORRELLAS SOCASTRO
eHealth AIL Coordinator
R+D Salut

M. 616.21.72.97

[hidden email]
skype:sergi.torrellas



BARCELONA DIGITAL CENTRE TECNOLÒGIC
R
oc Boronat 117, 5a planta, 08018 Barcelona 
Tel. +34 93 553 45 40 - Fax. +34 93 553 45 41 

www.bdigital.org



------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Java Swing and maximize window

Laila
Could you post the solution of your problem please? I have the same one...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Java Swing and maximize window

Laila
In reply to this post by Sergi Torrellas
Ok, so I had the same error but it was because I was connected through SSH to my gumstix board.

You simply have to plug a monitor to your board following this tutorial: http://www.youtube.com/watch?v=FxxEBn8Z_PA
Indeed, the board needs its own desktop to display the graphic interface. Maybe you can avoid using another monitor using VNC Viewer but I didn't find out how to make VNC Viewer work on the gumstix...

Hope that will help someone one day !
Loading...