Tip Of Day Dialog : Dialog « Swing Components « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » Swing Components » Dialog 




Tip Of Day Dialog
    

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.KeyEvent;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextPane;

public class TipOfDay {
  public static void main(String[] args) {
    JDialog d = new JDialog((Frame)null,"Tip of the Day");

    JPanel basic = new JPanel();
    basic.setLayout(new BoxLayout(basic, BoxLayout.Y_AXIS));
    d.add(basic);

    JPanel topPanel = new JPanel(new BorderLayout(00));
    topPanel.setMaximumSize(new Dimension(4500));
    JLabel hint = new JLabel("This is the tip");
    hint.setBorder(BorderFactory.createEmptyBorder(10251010));
    topPanel.add(hint);

    JSeparator separator = new JSeparator();
    separator.setForeground(Color.gray);

    topPanel.add(separator, BorderLayout.SOUTH);

    basic.add(topPanel);

    JPanel textPanel = new JPanel(new BorderLayout());
    textPanel.setBorder(BorderFactory.createEmptyBorder(15251525));
    JTextPane pane = new JTextPane();

    pane.setContentType("text/html");
    String text = "<p><b>Content</b></p>";
    pane.setText(text);
    pane.setEditable(false);
    textPanel.add(new JScrollPane(pane));

    basic.add(textPanel);

    JPanel boxPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 200));

    JCheckBox box = new JCheckBox("Show Tips at startup");
    box.setMnemonic(KeyEvent.VK_S);

    boxPanel.add(box);
    basic.add(boxPanel);

    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);
    basic.add(bottom);

    bottom.setMaximumSize(new Dimension(4500));

    d.setSize(new Dimension(450350));
    d.setResizable(false);
    d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    d.setVisible(true);
  }
}

   
    
    
    
  














Related examples in the same category
1.Vista Transparent DialogVista Transparent Dialog
2.Use this modal dialog to let the user choose one string from a long list
3.Swing error dialog (Exception dialog)Swing error dialog (Exception dialog)
4.Swing Login Domain Dialog with animationSwing Login Domain Dialog with animation
5.Shake a dialog
6.About dialog
7.Login DialogLogin Dialog
8.The base class for standard dialogs.
9.Password Dialog
10.A popup dialog with a message and a scrollable list of items
11.Custom dialog box to enter dates
12.Dialog Panel
13.Login Panel
14.Exception dump and Dialog Box
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.