-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTipOfDay.java
More file actions
74 lines (65 loc) · 2.46 KB
/
TipOfDay.java
File metadata and controls
74 lines (65 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.awt.*;
import java.awt.event.KeyEvent;
import javax.swing.*;
public class TipOfDay extends JDialog
{
public TipOfDay()
{
// setup basic panel
JPanel basic = new JPanel();
basic.setLayout( new BoxLayout( basic, BoxLayout.Y_AXIS )); // vertical
// setup top panel
JPanel topPanel = new JPanel( new BorderLayout( 0, 0 ));
topPanel.setMaximumSize( new Dimension( 450, 0 ));
JLabel topicText = new JLabel( "Cute Animal Hints" );
topicText.setBorder( BorderFactory.createEmptyBorder( 0, 25, 0, 0 ));
JLabel topicIcon = new JLabel( new ImageIcon( "panda.png" ));
topicIcon.setBorder( BorderFactory.createEmptyBorder( 5, 5, 5, 5 ));
JSeparator sep = new JSeparator();
sep.setForeground( Color.gray );
topPanel.add( topicText );
topPanel.add( topicIcon, BorderLayout.EAST );
topPanel.add( sep, BorderLayout.SOUTH );
basic.add( topPanel );
// setup main text panel
JPanel textPanel = new JPanel( new BorderLayout() );
textPanel.setBorder( BorderFactory.createEmptyBorder( 15, 25, 15, 25 ));
JTextPane pane = new JTextPane();
pane.setContentType("text/html");
String text = "<p><b>How to choose cute animals for your projects</b></p>" +
"<p>The animal has to be somewhat realistic, and preferrably in color. " +
"It's best if the animal is a cartoon with a happy expression.</p>";
pane.setText( text );
pane.setEditable( false );
textPanel.add( pane );
basic.add( textPanel );
// setup option to show panel
JPanel boxPanel = new JPanel( new FlowLayout( FlowLayout.LEFT, 20, 0 ));
JCheckBox cbox = new JCheckBox( "Don't show next time" );
cbox.setMnemonic( KeyEvent.VK_D );
boxPanel.add( cbox );
basic.add( boxPanel );
// setup dialog buttons
JPanel bottom = new JPanel( new FlowLayout( FlowLayout.RIGHT ));
JButton ntip = new JButton( "Next Tip" );
ntip.setMnemonic( KeyEvent.VK_N );
JButton close = new JButton( "Close" );
close.setMnemonic( KeyEvent.VK_C );
bottom.add( ntip );
bottom.add( close );
bottom.setMaximumSize( new Dimension( 450, 0 ));
basic.add( bottom );
add( basic );
// set dialog attributes
setTitle( "Example" );
setSize( 450, 350 );
setResizable( false );
setLocationRelativeTo( null );
setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE );
}
public static void main( String[] args )
{
TipOfDay ex = new TipOfDay();
ex.setVisible( true );
}
}