Biblioteca Java - Blame information for rev 32
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
32 | mihai | 1 | /* |
2 | * To change this license header, choose License Headers in Project Properties. | ||
3 | * To change this template file, choose Tools | Templates | ||
4 | * and open the template in the editor. | ||
5 | */ | ||
6 | package guidemo; | ||
7 | |||
8 | import java.awt.Color; | ||
9 | import java.awt.Container; | ||
10 | import java.awt.FlowLayout; | ||
11 | import javax.swing.*; | ||
12 | import javax.swing.plaf.nimbus.NimbusLookAndFeel; | ||
13 | |||
14 | public class JFrameExample extends JFrame { | ||
15 | public static void main(String[] args) { | ||
16 | JFrame frame = new JFrameExample("This is a test"); | ||
17 | frame.setVisible(true); | ||
18 | } | ||
19 | |||
20 | public JFrameExample(String title) { | ||
21 | super(title); | ||
22 | //WindowUtilities.setNativeLookAndFeel(); | ||
23 | setSize(300, 100); | ||
24 | Container content = getContentPane(); | ||
25 | content.setBackground(Color.WHITE); | ||
26 | content.setLayout(new FlowLayout()); | ||
27 | content.add(new JButton("Button 1")); | ||
28 | content.add(new JButton("Button 2")); | ||
29 | content.add(new JButton("Button 3")); | ||
30 | setDefaultCloseOperation(EXIT_ON_CLOSE); | ||
31 | } | ||
32 | } | ||
33 | |||
34 | class WindowUtilities { | ||
35 | public static void setNativeLookAndFeel() { | ||
36 | try { | ||
37 | NimbusLookAndFeel nlf = new NimbusLookAndFeel(); | ||
38 | UIManager.setLookAndFeel( | ||
39 | UIManager.setLookAndFeel(nlf) | ||
40 | ); | ||
41 | } catch(Exception e) { | ||
42 | System.out.println("Error setting native LAF: " | ||
43 | + e); | ||
44 | } | ||
45 | } | ||
46 | } |