Pawel Debski – SW Development and other thoughts

http://econsulting.pl/ Java, Microsoft.Net C#, TIBCO, WebMethods, Oracle, Informatica

Archive for May 2013

Java Swing setMaximumSize does not work

A friend studying IT got an exercise to write a nice & simple app in #Java #Swing to draw a few things. He did quite a nice coding and the app works like a charm. He did not manage however to do one thing: #limit the #maximum #size of the #window and he asked me, the famous consultant and top-notch developer, for help. Being a superhero I could not refuse – my blazing-fast fingers touched the keyboard just like I’d be Chopin and… bdzionk. It did not work. #setMaximumSize (new #Dimension (max_x, max_y)) simply does not work for me. After few hours of trying and googling I found a #workaround which is not elegant and does not look good to user. I still have no right #solution. Perhaps you, my dear network, can help me with it? Or at least explain why it does not work?

Here are the details:

public class SwingExercise

extends JApplet

implements Runnable // to update some simple animation

{

    // some variables go here

    // including timer, action listeners, etc.

    public SwingExercise() throws HeadlessException {

        super();

        // this works…

        this.setMinimumSize(new Dimension(min_x, min_y));

        // this does not

        this.setMaximumSize(new Dimension(max_x, max_y));

        // this also works…

        this.setPreferredSize(new Dimension(initial_x, initial_y));

    }

    public void paint(Graphics g) {

        super.paint(g);

        Graphics2D g2 = (Graphics2D) g;

        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        this.wndSz = getSize();   

        if(debug_wndSz){

            System.out.print(“Window size: t”);

            System.out.println(this.wndSize);

            boolean isMaximumSS=this.isMaximumSizeSet();

            System.out.print(“isMaximumSizeSet? t”);

            System.out.println(isMaximumSS);

            if(isMaximumSS){

                System.out.print(“Max window size: t”);

                System.out.println(this.getMaximumSize());                

            }

        }

        // other painting goes here

    }

    private void createAndShowGUI() {

        JFrame.setDefaultLookAndFeelDecorated(true);

        JFrame frame = new JFrame(“Swing Exercise”);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        frame.getContentPane().add(“Center”, this);

        frame.pack();

        frame.setVisible(true);

    }

    public void run() {

        createAndShowGUI();

        this.paintingTimer.start();

    }

    public static void main(String[] args) {

        javax.swing.SwingUtilities.invokeLater(new SwingExercise());

    }

}

Here is the console output after some resizing:

Window size: java.awt.Dimension[width=858,height=467]

isMaximumSizeSet? true

Max window size: java.awt.Dimension[width=800,height=400]

I gaped on this output for some time and tried to apply setMaximumSize to all the components I could find, including JFrame, frame.getContentPane() but nothing worked. I found another solution with no use of setMaximumSize, but I do not like it. Really, we shall make setMaximumSize work somehow.

Written by Pawel Debski

2013/05/25 at 21:34

Xen virtualisation support dropped by Red Hat 6 and therefore in CentOS 6

We are preparing the upgrade of our Linux infrastructure and… bdzionk: Xen support dropped by Red Hat 6 and therefore in CentOS 6:

Maybe it is a RedHat play or maybe Xen inherent design flaw as pointed-out below:

“Linux kernel developers say no to Xen”

http://searchenterpriselinux.techtarget.com/news/1511180/Linux-community-turning-away-from-Xen-virtualization

Linus Torvalds: “The point? Xen really is horribly badly separated out. It gets way more incestuous with other systems than it should. It’s entirely possible that this is very fundamental to both paravirtualization and to hypervisor behavior, but it doesn’t matter – it just measn that I can well see that Xen is a f*cking pain to merge. So please, Xen people, look at your track record, and look at the issues from the standpoint of somebody merging your code, rather than just from the standpoint of somebody who whines “I want my code to be merged”.”

http://lkml.indiana.edu/hypermail/linux/kernel/0906.0/00870.html

The fact is that nowadays using Xen with CentOS is pain in the a.s so we’ve decided to give KVM a try.

Apparently Xen developers started to address the issue as evidenced in http://blog.xen.org/ – despite dooming voices Xen thrives and perhaps in the future we we’ll be back to it.

Here is a nice How-to on KVM and #CentOS6:

http://www.howtoforge.com/virtualization-with-kvm-on-a-centos-6.3-server

Please be sure to read #SELinux remarks and links in the comments section of the article – leaving SELinux enabled considerably increases security of the whole installation and in my opinion this is the professional way to do it.

Apparently it is possible to use virtualisation with SELinux: 

http://www.centos.org/docs/5/html/5.2/Virtualization/chap-Virtualization-SELinux_and_virtualization.html

I wonder which one is more SELinux-friendly: KVM or XEN? Any opinions?

Finally a few additional links

For those who’d like to stick with Xen:

Comparing XEN and KVM (in Polish):

Written by Pawel Debski

2013/05/12 at 18:08

Posted in Uncategorized

Tagged with , , , ,

Trudny proces wyboru liceum

Mieszkamy w Pruszkowie, a mój syn właśnie kończy gimnazjum. 

Pruszków k. Warszawy

Do wyboru liceum podeszliśmy metodycznie i naukowo – faktycznie kurczę jesteśmy podobni:

  • wysoki poziom, ale żeby nie cisnęli za bardzo
  • w miarę dobry dojazd

Zaczęliśmy od wynotowania pruszkowskich liceów oraz tych w pobliżu SKM/WKD w Warszawie.

Oto wyniki, rankingu Perspektyw dla wybranych liceów:

Ranking liceów w okolicy

Niestety inne licea w okolicy (Zan, Komorów, Piastów i Podkowa Leśna) mają tak niski poziom, że są albo na szarym końcu, albo wręcz poza rankingiem.

Oto moje poglądy na temat wyboru:

  • do Staszica i tak nie damy rady, zresztą nie ma co się zarzynać,
  • z dużą satysfakcją stwierdzam wysoki poziom mojego liceum, tj. mojej ukochanej Hoffmanowej,
  • Kuroń odpada bo humanistyczny,
  • Kościuch nie wypada wcale tak źle, zresztą mój starszy syn po Kościuchu dostał się spox na Politechnikę.

Na koniec parę linków do zasad rekrutacji:

Teraz wiemy już gdzie składać, a co ostatecznie mój syn wybierze to się okaże po konsultacjach środowiskowych 😉

Written by Pawel Debski

2013/05/11 at 15:11

Posted in Uncategorized

Tagged with , , , ,