> France flag in Java?

France flag in Java?

Posted at: 2014-12-18 
how can you get a france flag in java programming in netbeans

That's just blue, white and red colored rectangles. If you're using the forms designer, you can add and size three Panel containers with different background colors side-by-side in a larger Panel that represents the whole flag.

Writing your own Swing code is easy on this one. First, I'd make a utility class to represent one flag panel (declared static because I have it inside my application class):

static class FlagPanel extends JPanel {

public FlagPanel( int width, int height, Color color ) {

Dimension size = new Dimension(width, height);

setMaximumSize(size);

setMinimumSize(size);

setPreferredSize(size);

setBackground(color);

}

} // FlagPanel class

Not much to it, huh? That class is actually generally useful for creating fixed-size colored panels for any purpose. Then you can make the container panel with:

JPanel flagPanel = new JPanel();

flagPanel.setLayout(new BoxLayout(flagPanel, BoxLayout.X_AXIS));

flagPanel.add(new FlagPanel(200, 400, new Color(0,85,164)));

flagPanel.add(new FlagPanel(200, 400, new Color(255,255,255)));

flagPanel.add(new FlagPanel(200, 400, new Color(250,60,50)));

Those colors are (according the Wikipedia) the official RGB colors from the flag of France, by the way, and the 600x400 overall size fits the 3:2 aspect ratio too. See:

http://en.wikipedia.org/wiki/Flag_of_Fra...

how can you get a france flag in java programming in netbeans