Biblioteca Java - Rev 32

Subversion Repositories:
Rev:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package guidemo;

import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.*;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;

public class JFrameExample extends JFrame {
  public static void main(String[] args) {
    JFrame frame = new JFrameExample("This is a test");
    frame.setVisible(true);
  }
 
  public JFrameExample(String title) {
    super(title);
    //WindowUtilities.setNativeLookAndFeel();
    setSize(300, 100);
    Container content = getContentPane();
    content.setBackground(Color.WHITE);
    content.setLayout(new FlowLayout());
    content.add(new JButton("Button 1"));
    content.add(new JButton("Button 2"));
    content.add(new JButton("Button 3"));
    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
}

class WindowUtilities {
  public static void setNativeLookAndFeel() {
    try {
      NimbusLookAndFeel nlf =  new NimbusLookAndFeel();
        UIManager.setLookAndFeel(
       UIManager.setLookAndFeel(nlf)
     );
    } catch(Exception e) {
      System.out.println("Error setting native LAF: "
                         + e);
    }
  }
}