copy welcome screen code from 5.0 netbeans codebase.
1.1 --- a/bluej-suite/bluej-welcome/nbproject/project.xml Fri Apr 21 16:59:21 2006 +0000
1.2 +++ b/bluej-suite/bluej-welcome/nbproject/project.xml Mon Apr 24 13:11:49 2006 +0000
1.3 @@ -53,6 +53,14 @@
1.4 <run-dependency/>
1.5 </dependency>
1.6 <dependency>
1.7 + <code-name-base>org.openide.filesystems</code-name-base>
1.8 + <build-prerequisite/>
1.9 + <compile-dependency/>
1.10 + <run-dependency>
1.11 + <specification-version>6.4</specification-version>
1.12 + </run-dependency>
1.13 + </dependency>
1.14 + <dependency>
1.15 <code-name-base>org.openide.util</code-name-base>
1.16 <build-prerequisite/>
1.17 <compile-dependency/>
2.1 --- a/bluej-suite/bluej-welcome/src/org/netbeans/bluej/welcome/BluejWelcomeTopComponent.form Fri Apr 21 16:59:21 2006 +0000
2.2 +++ b/bluej-suite/bluej-welcome/src/org/netbeans/bluej/welcome/BluejWelcomeTopComponent.form Mon Apr 24 13:11:49 2006 +0000
2.3 @@ -1,6 +1,6 @@
2.4 <?xml version="1.0" encoding="UTF-8" ?>
2.5
2.6 -<Form version="1.3">
2.7 +<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
2.8 <AuxValues>
2.9 <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
2.10 <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
2.11 @@ -8,44 +8,5 @@
2.12 <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
2.13 </AuxValues>
2.14
2.15 - <Layout>
2.16 - <DimensionLayout dim="0">
2.17 - <Group type="103" groupAlignment="0" attributes="0">
2.18 - <Group type="102" alignment="0" attributes="0">
2.19 - <EmptySpace max="-2" attributes="0"/>
2.20 - <Component id="jPanel1" max="32767" attributes="0"/>
2.21 - <EmptySpace max="-2" attributes="0"/>
2.22 - </Group>
2.23 - </Group>
2.24 - </DimensionLayout>
2.25 - <DimensionLayout dim="1">
2.26 - <Group type="103" groupAlignment="0" attributes="0">
2.27 - <Group type="102" alignment="1" attributes="0">
2.28 - <EmptySpace max="-2" attributes="0"/>
2.29 - <Component id="jPanel1" max="32767" attributes="0"/>
2.30 - <EmptySpace max="-2" attributes="0"/>
2.31 - </Group>
2.32 - </Group>
2.33 - </DimensionLayout>
2.34 - </Layout>
2.35 - <SubComponents>
2.36 - <Container class="javax.swing.JPanel" name="jPanel1">
2.37 - <AuxValues>
2.38 - <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="jPanel1 = new ImagePanel();"/>
2.39 - </AuxValues>
2.40 -
2.41 - <Layout>
2.42 - <DimensionLayout dim="0">
2.43 - <Group type="103" groupAlignment="0" attributes="0">
2.44 - <EmptySpace min="0" pref="451" max="32767" attributes="0"/>
2.45 - </Group>
2.46 - </DimensionLayout>
2.47 - <DimensionLayout dim="1">
2.48 - <Group type="103" groupAlignment="0" attributes="0">
2.49 - <EmptySpace min="0" pref="375" max="32767" attributes="0"/>
2.50 - </Group>
2.51 - </DimensionLayout>
2.52 - </Layout>
2.53 - </Container>
2.54 - </SubComponents>
2.55 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
2.56 </Form>
3.1 --- a/bluej-suite/bluej-welcome/src/org/netbeans/bluej/welcome/BluejWelcomeTopComponent.java Fri Apr 21 16:59:21 2006 +0000
3.2 +++ b/bluej-suite/bluej-welcome/src/org/netbeans/bluej/welcome/BluejWelcomeTopComponent.java Mon Apr 24 13:11:49 2006 +0000
3.3 @@ -5,6 +5,7 @@
3.4 import java.awt.Image;
3.5 import java.awt.LayoutManager;
3.6 import java.io.Serializable;
3.7 +import javax.swing.JPanel;
3.8 import org.openide.ErrorManager;
3.9 import org.openide.util.NbBundle;
3.10 import org.openide.util.Utilities;
3.11 @@ -23,9 +24,11 @@
3.12 static final String ICON_PATH = "org/netbeans/bluej/welcome/frame.gif";
3.13
3.14 private static final String PREFERRED_ID = "BluejWelcomeTopComponent";
3.15 -
3.16 + private JPanel panel;
3.17 private BluejWelcomeTopComponent() {
3.18 initComponents();
3.19 + panel = new TitlePanel50();
3.20 + add(panel);
3.21 setName(NbBundle.getMessage(BluejWelcomeTopComponent.class, "CTL_BluejWelcomeTopComponent"));
3.22 setToolTipText(NbBundle.getMessage(BluejWelcomeTopComponent.class, "HINT_BluejWelcomeTopComponent"));
3.23 setIcon(Utilities.loadImage(ICON_PATH, true));
3.24 @@ -38,42 +41,19 @@
3.25 */
3.26 // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
3.27 private void initComponents() {
3.28 - jPanel1 = jPanel1 = new ImagePanel();
3.29
3.30 - org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
3.31 - jPanel1.setLayout(jPanel1Layout);
3.32 - jPanel1Layout.setHorizontalGroup(
3.33 - jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
3.34 - .add(0, 451, Short.MAX_VALUE)
3.35 - );
3.36 - jPanel1Layout.setVerticalGroup(
3.37 - jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
3.38 - .add(0, 375, Short.MAX_VALUE)
3.39 - );
3.40 + setLayout(new java.awt.BorderLayout());
3.41
3.42 - org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
3.43 - this.setLayout(layout);
3.44 - layout.setHorizontalGroup(
3.45 - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
3.46 - .add(layout.createSequentialGroup()
3.47 - .addContainerGap()
3.48 - .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
3.49 - .addContainerGap())
3.50 - );
3.51 - layout.setVerticalGroup(
3.52 - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
3.53 - .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
3.54 - .addContainerGap()
3.55 - .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
3.56 - .addContainerGap())
3.57 - );
3.58 }// </editor-fold>//GEN-END:initComponents
3.59
3.60
3.61 // Variables declaration - do not modify//GEN-BEGIN:variables
3.62 - private javax.swing.JPanel jPanel1;
3.63 // End of variables declaration//GEN-END:variables
3.64
3.65 + public void addNotify() {
3.66 + super.addNotify();
3.67 +
3.68 + }
3.69
3.70 /**
3.71 * Gets default instance. Do not use directly: reserved for *.settings files only,
3.72 @@ -132,19 +112,4 @@
3.73 }
3.74
3.75
3.76 - public class ImagePanel extends javax.swing.JPanel {
3.77 -
3.78 - public ImagePanel() {
3.79 - }
3.80 -
3.81 - /** Paint custom background. */
3.82 - public void paint(Graphics g) {
3.83 -
3.84 - int xx = getWidth();
3.85 - int yy = getHeight();
3.86 - Image image = Utilities.loadImage("org/netbeans/bluej/welcome/welcome-placeholder.png"); // NOI18N
3.87 - g.drawImage(image, (xx-632)/2, (yy-447)/2, this);
3.88 - }
3.89 - }
3.90 -
3.91 }
4.1 --- a/bluej-suite/bluej-welcome/src/org/netbeans/bluej/welcome/Bundle.properties Fri Apr 21 16:59:21 2006 +0000
4.2 +++ b/bluej-suite/bluej-welcome/src/org/netbeans/bluej/welcome/Bundle.properties Mon Apr 24 13:11:49 2006 +0000
4.3 @@ -2,3 +2,18 @@
4.4 CTL_BluejWelcomeTopComponent=Welcome
4.5 HINT_BluejWelcomeTopComponent=Welcome
4.6 OpenIDE-Module-Name=bluej-welcome
4.7 +
4.8 +HTML_QUICKSTART=http://www.bluej.org/netbeans/tutorial
4.9 +HTML_NEWS=nbinst:///docs/whatsnew.html
4.10 +
4.11 +#following URLs could be changed to localized websites if exixts
4.12 +HTML_modules=http://edu.netbeans.org
4.13 +HTML_Collab=http://www.bluej.org/netbeans
4.14 +HTML_SUN=http://www.sun.com
4.15 +HTML_JAVA=http://java.sun.com
4.16 +HTML_NB=http://www.netbeans.org
4.17 +
4.18 +BK0001=What's New
4.19 +BK0002=Tutorials
4.20 +BK0003=NetBeans IDE
4.21 +BK0004=BlueJ
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/bluej-suite/bluej-welcome/src/org/netbeans/bluej/welcome/BusinessLogic.java Mon Apr 24 13:11:49 2006 +0000
5.3 @@ -0,0 +1,155 @@
5.4 +/*
5.5 + * Sun Public License Notice
5.6 + *
5.7 + * The contents of this file are subject to the Sun Public License
5.8 + * Version 1.0 (the "License"). You may not use this file except in
5.9 + * compliance with the License. A copy of the License is available at
5.10 + * http://www.sun.com/
5.11 + *
5.12 + * The Original Code is NetBeans. The Initial Developer of the Original
5.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
5.14 + * Microsystems, Inc. All Rights Reserved.
5.15 + */
5.16 +
5.17 +package org.netbeans.bluej.welcome;
5.18 +
5.19 +import java.awt.Component;
5.20 +import java.awt.Cursor;
5.21 +import java.net.MalformedURLException;
5.22 +import java.net.URL;
5.23 +import javax.swing.JComponent;
5.24 +import javax.swing.JFrame;
5.25 +import javax.swing.SwingUtilities;
5.26 +import org.openide.ErrorManager;
5.27 +import org.openide.awt.HtmlBrowser;
5.28 +import org.openide.filesystems.FileObject;
5.29 +import org.openide.filesystems.URLMapper;
5.30 +import org.openide.util.HelpCtx;
5.31 +import org.openide.util.Lookup;
5.32 +import org.openide.util.NbBundle;
5.33 +//import org.netbeans.api.javahelp.Help;
5.34 +
5.35 +/**
5.36 + * Handles welcome screen buttons. It should be loaded
5.37 + * into memory only if a button pressed saving few ms.
5.38 + *
5.39 + * @author Petr Kuzel
5.40 + */
5.41 +final class BusinessLogic {
5.42 +
5.43 + private static final int THREE_SECONDS = 3 * 1000;
5.44 +
5.45 + /**
5.46 + *
5.47 + * @param opcode 1-6 for button set. 101 top log, 102 bottom logo
5.48 + */
5.49 + static void perform(int opcode, JComponent client) {
5.50 + switch (opcode) {
5.51 + case 1:
5.52 + showURL("HTML_NEWS", client); // NOI18N
5.53 + break;
5.54 + case 2:
5.55 + showURL("HTML_QUICKSTART", client); // NOI18N
5.56 + break;
5.57 + case 3:
5.58 + showURL("HTML_modules", client); // NOI18N
5.59 + break;
5.60 + case 4:
5.61 + showURL("HTML_Collab", client); // NOI18N
5.62 + break;
5.63 + case 5:
5.64 + showURL("HTML_Profiler", client); // NOI18N
5.65 + break;
5.66 + case 6:
5.67 + showURL("HTML_J2ME", client); // NOI18N
5.68 + break;
5.69 + case 101:
5.70 + showURL("HTML_JAVA", client); // NOI18N
5.71 + break;
5.72 + case 102:
5.73 + showURL("HTML_SUN", client); // NOI18N
5.74 + break;
5.75 + case 103:
5.76 + showURL("HTML_NB", client); // NOI18N
5.77 + break;
5.78 + default:
5.79 + assert false : "Unexpected operation code: " + opcode; // NOI18N
5.80 + }
5.81 + }
5.82 +
5.83 + private static void showURL(String bundleKey, JComponent client) {
5.84 + try {
5.85 + start(client);
5.86 + URL url = new URL(NbBundle.getMessage(BusinessLogic.class, bundleKey));
5.87 + if (url.getProtocol().equalsIgnoreCase("nbinst")) {
5.88 + url = externalizeURL(url); // NOI18N
5.89 + }
5.90 + HtmlBrowser.URLDisplayer.getDefault().showURL(url);
5.91 + } catch (java.net.MalformedURLException ex) {
5.92 + ErrorManager.getDefault().notify(ex);
5.93 + } finally {
5.94 + // waiting for #63987
5.95 + // done(client);
5.96 + }
5.97 + }
5.98 +
5.99 +// private static void showHelp(String id, JComponent client) {
5.100 +// Help help = (Help) Lookup.getDefault().lookup(Help.class);
5.101 +// if (help != null) {
5.102 +// try {
5.103 +// start(client);
5.104 +// help.showHelp(new HelpCtx(id));
5.105 +// } finally {
5.106 +// done(client);
5.107 +// }
5.108 +// }
5.109 +// }
5.110 +
5.111 + /**
5.112 + * Enables glass pane for max 3sec. It disallows
5.113 + * user to select same slow action by accident two times.
5.114 + */
5.115 + private static void start(final JComponent client) {
5.116 + Component root = SwingUtilities.getRoot(client);
5.117 + final Component glasspane = (root instanceof JFrame) ? ((JFrame)root).getGlassPane() : null;
5.118 +
5.119 + // do the timeouting waiting cursor
5.120 + if (glasspane != null) {
5.121 + glasspane.setVisible(true);
5.122 + glasspane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
5.123 + }
5.124 +
5.125 + org.openide.util.RequestProcessor.getDefault().post(new Runnable() {
5.126 + public void run() {
5.127 + done(client);
5.128 + }
5.129 + }, THREE_SECONDS);
5.130 + }
5.131 +
5.132 + /**
5.133 + * Hides the glass pane.
5.134 + */
5.135 + private static void done(JComponent client) {
5.136 + Component root = SwingUtilities.getRoot(client);
5.137 + final Component glasspane = (root instanceof JFrame) ? ((JFrame)root).getGlassPane() : null;
5.138 + if (glasspane!=null) {
5.139 + glasspane.setCursor(Cursor.getDefaultCursor());
5.140 + glasspane.setVisible(false);
5.141 + }
5.142 + }
5.143 +
5.144 + private static URL externalizeURL(URL url) {
5.145 + FileObject fo = URLMapper.findFileObject(url);
5.146 + if (fo == null) {
5.147 + try {
5.148 + return new URL("http://www.netbeans.org"); // NOI18N
5.149 + } catch (MalformedURLException ex) {
5.150 + // ignore
5.151 + return null;
5.152 + }
5.153 + } else {
5.154 + return URLMapper.findURL(fo,URLMapper.EXTERNAL);
5.155 + }
5.156 + }
5.157 +
5.158 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/bluej-suite/bluej-welcome/src/org/netbeans/bluej/welcome/OvalButton.java Mon Apr 24 13:11:49 2006 +0000
6.3 @@ -0,0 +1,109 @@
6.4 +/*
6.5 + * Sun Public License Notice
6.6 + *
6.7 + * The contents of this file are subject to the Sun Public License
6.8 + * Version 1.0 (the "License"). You may not use this file except in
6.9 + * compliance with the License. A copy of the License is available at
6.10 + * http://www.sun.com/
6.11 + *
6.12 + * The Original Code is NetBeans. The Initial Developer of the Original
6.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
6.14 + * Microsystems, Inc. All Rights Reserved.
6.15 + */
6.16 +
6.17 +
6.18 +package org.netbeans.bluej.welcome;
6.19 +
6.20 +import java.awt.*;
6.21 +import javax.swing.*;
6.22 +import java.awt.event.*;
6.23 +import org.openide.util.Utilities;
6.24 +
6.25 +
6.26 +/**
6.27 + * Transparent button with bullet rollover effect.
6.28 + *
6.29 + * @author Petr Kuzel
6.30 + */
6.31 +public class OvalButton extends JButton implements MouseListener {
6.32 +
6.33 + private float scale = 1.0f;
6.34 +
6.35 + // conatants dictated by graphics
6.36 + private static final int MAX_FONT = 18;
6.37 + private static final int MIN_FONT = 13;
6.38 +
6.39 + private boolean mouseOver;
6.40 +
6.41 + public OvalButton() {
6.42 + super();
6.43 + addMouseListener(this);
6.44 + }
6.45 +
6.46 +
6.47 + public void paint(Graphics g) {
6.48 + Graphics2D g2d = (Graphics2D)g;
6.49 + int xx = getWidth();
6.50 + int yy = getHeight();
6.51 +
6.52 + Image bullet;
6.53 + if (getModel().isArmed() || mouseOver) {
6.54 + bullet = Utilities.loadImage("org/netbeans/bluej/welcome/button-over.png"); // NOI18N
6.55 + } else {
6.56 + bullet = Utilities.loadImage("org/netbeans/bluej/welcome/button-gray.png"); // NOI18N
6.57 + }
6.58 + ImageIcon icon = new ImageIcon(bullet);
6.59 + int icon_h = icon.getIconHeight();
6.60 + int icon_w = icon.getIconWidth();
6.61 + g.drawImage(bullet, 0, (yy-icon_w)/2, this);
6.62 +
6.63 + int text_x = icon_w + 6;
6.64 + Font f = getFont();
6.65 + FontMetrics fm = g.getFontMetrics(f);
6.66 + g.setFont(f);
6.67 + g.setColor(Color.WHITE);
6.68 + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
6.69 + g.drawString(getText(),text_x, yy/2 + (fm.getAscent()+fm.getDescent())/2 - fm.getDescent());
6.70 + }
6.71 +
6.72 + public void setScale(float scale) {
6.73 + this.scale = scale;
6.74 + }
6.75 +
6.76 + public Font getFont() {
6.77 + Font oldFont = super.getFont();
6.78 + if (oldFont!=null) {
6.79 + int size = Math.max(oldFont.getSize(), MIN_FONT);
6.80 + size *= scale;
6.81 + size = Math.min(size, MAX_FONT);
6.82 + Font newFont = new Font("SansSerif", Font.BOLD, size); // NOI18N
6.83 + return newFont;
6.84 + } else {
6.85 + return null;
6.86 + }
6.87 + }
6.88 +
6.89 + public boolean isOpaque() {
6.90 + return false;
6.91 + }
6.92 +
6.93 + public void mouseClicked(MouseEvent e) {
6.94 + }
6.95 +
6.96 + public void mousePressed(MouseEvent e) {
6.97 + }
6.98 +
6.99 + public void mouseReleased(MouseEvent e) {
6.100 + }
6.101 +
6.102 + public void mouseEntered(MouseEvent e) {
6.103 + mouseOver = true;
6.104 + repaint(0);
6.105 + }
6.106 +
6.107 + public void mouseExited(MouseEvent e) {
6.108 + mouseOver = false;
6.109 + repaint(0);
6.110 + }
6.111 +
6.112 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/bluej-suite/bluej-welcome/src/org/netbeans/bluej/welcome/TitlePanel50.form Mon Apr 24 13:11:49 2006 +0000
7.3 @@ -0,0 +1,76 @@
7.4 +<?xml version="1.0" encoding="UTF-8" ?>
7.5 +
7.6 +<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
7.7 + <AuxValues>
7.8 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
7.9 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="2"/>
7.10 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
7.11 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
7.12 + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
7.13 + </AuxValues>
7.14 +
7.15 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
7.16 + <SubComponents>
7.17 + <Component class="javax.swing.JButton" name="jButton1">
7.18 + <Properties>
7.19 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
7.20 + <ResourceString bundle="org/netbeans/bluej/welcome/Bundle.properties" key="BK0001" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
7.21 + </Property>
7.22 + <Property name="focusable" type="boolean" value="false"/>
7.23 + </Properties>
7.24 + <Events>
7.25 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
7.26 + </Events>
7.27 + <AuxValues>
7.28 + <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new OvalButton();"/>
7.29 + </AuxValues>
7.30 + </Component>
7.31 + <Component class="javax.swing.JButton" name="jButton2">
7.32 + <Properties>
7.33 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
7.34 + <ResourceString bundle="org/netbeans/bluej/welcome/Bundle.properties" key="BK0002" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
7.35 + </Property>
7.36 + <Property name="focusable" type="boolean" value="false"/>
7.37 + </Properties>
7.38 + <Events>
7.39 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
7.40 + </Events>
7.41 + <AuxValues>
7.42 + <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new OvalButton();"/>
7.43 + </AuxValues>
7.44 + </Component>
7.45 + <Component class="javax.swing.JButton" name="jButton3">
7.46 + <Properties>
7.47 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
7.48 + <ResourceString bundle="org/netbeans/bluej/welcome/Bundle.properties" key="BK0003" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
7.49 + </Property>
7.50 + <Property name="focusable" type="boolean" value="false"/>
7.51 + </Properties>
7.52 + <Events>
7.53 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/>
7.54 + </Events>
7.55 + <AuxValues>
7.56 + <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new OvalButton();"/>
7.57 + </AuxValues>
7.58 + </Component>
7.59 + <Component class="javax.swing.JButton" name="jButton4">
7.60 + <Properties>
7.61 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
7.62 + <ResourceString bundle="org/netbeans/bluej/welcome/Bundle.properties" key="BK0004" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
7.63 + </Property>
7.64 + <Property name="focusable" type="boolean" value="false"/>
7.65 + </Properties>
7.66 + <Events>
7.67 + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton4ActionPerformed"/>
7.68 + </Events>
7.69 + <AuxValues>
7.70 + <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new OvalButton();"/>
7.71 + </AuxValues>
7.72 + </Component>
7.73 + <Component class="javax.swing.JLabel" name="jLabel3">
7.74 + <Events>
7.75 + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jLabel3MouseClicked"/>
7.76 + </Events>
7.77 + </Component>
7.78 + </SubComponents>
7.79 +</Form>
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/bluej-suite/bluej-welcome/src/org/netbeans/bluej/welcome/TitlePanel50.java Mon Apr 24 13:11:49 2006 +0000
8.3 @@ -0,0 +1,356 @@
8.4 +/*
8.5 + * Sun Public License Notice
8.6 + *
8.7 + * The contents of this file are subject to the Sun Public License
8.8 + * Version 1.0 (the "License"). You may not use this file except in
8.9 + * compliance with the License. A copy of the License is available at
8.10 + * http://www.sun.com/
8.11 + *
8.12 + * The Original Code is NetBeans. The Initial Developer of the Original
8.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
8.14 + * Microsystems, Inc. All Rights Reserved.
8.15 + */
8.16 +
8.17 +package org.netbeans.bluej.welcome;
8.18 +
8.19 +import java.awt.Color;
8.20 +import java.awt.Component;
8.21 +import java.awt.Container;
8.22 +import java.awt.Cursor;
8.23 +import java.awt.Dimension;
8.24 +import java.awt.GradientPaint;
8.25 +import java.awt.Graphics;
8.26 +import java.awt.Graphics2D;
8.27 +import java.awt.Image;
8.28 +import java.awt.LayoutManager;
8.29 +import java.awt.Paint;
8.30 +import java.awt.Point;
8.31 +import java.awt.geom.Point2D;
8.32 +import javax.swing.ImageIcon;
8.33 +import javax.swing.JComponent;
8.34 +import javax.swing.SwingUtilities;
8.35 +import org.openide.util.Utilities;
8.36 +
8.37 +/**
8.38 + * Wecome screen UI, mostly assembled at runtime. It has custom:
8.39 + * <ul>
8.40 + * <li>paint() method to draw background
8.41 + * <li>layout manager to precisely place components on background image
8.42 + * </ul>
8.43 + *
8.44 + * <p>The cod eit full of static constants to avoid expensive
8.45 + * runtime computations (during startup).
8.46 + *
8.47 + * @author Petr Kuzel
8.48 + */
8.49 +public class TitlePanel50 extends javax.swing.JPanel implements Runnable, java.awt.event.ActionListener, java.awt.event.MouseListener, LayoutManager {
8.50 +
8.51 + private final ImageIcon background;
8.52 + private int backgroundWidth = -1;
8.53 + private int backgroundHeight = -1;
8.54 +
8.55 + private static final Color TOP_COLOR = new Color(224,221,209); // measured from gradient.png
8.56 + private static final Color BOT_COLOR = new Color(217,207,174); // measured from gradient.png
8.57 +
8.58 + private static final int BUTTONS_X_OFFSET = 380; // taken from measuring background.png
8.59 +
8.60 + // it's tiled, values measured from gradient.png
8.61 + private static final int GRADIENT_WIDTH = 53;
8.62 + private static final int GRADIENT_HEIGHT = 89;
8.63 +
8.64 + // background has tranparent edge
8.65 + private static final int TRANSPARENT_EDGE_WIDTH = 15;
8.66 +
8.67 + public TitlePanel50() {
8.68 + background = new ImageIcon(Utilities.loadImage("org/netbeans/bluej/welcome/welcome-placeholder.png")); // NOI18N
8.69 + initComponents();
8.70 +
8.71 + ((OvalButton)jButton1).setScale(1.333f);
8.72 + ((OvalButton)jButton2).setScale(1.333f);
8.73 + setLayout(this);
8.74 + setOpaque(false);
8.75 + }
8.76 +
8.77 + /** Paint custom background. */
8.78 + public void paint(Graphics g) {
8.79 +
8.80 +// long start = System.currentTimeMillis();
8.81 +
8.82 + Graphics2D g2d = (Graphics2D)g;
8.83 + int xx = getWidth();
8.84 + int yy = getHeight();
8.85 +
8.86 + int offset_x = (xx - backgroundWidth())/2;
8.87 + int offset_y = (yy - backgroundHeight())/2;
8.88 +
8.89 + // gradient background
8.90 + g2d.setColor(TOP_COLOR);
8.91 + g2d.fillRect(0, 0, xx, (yy-GRADIENT_HEIGHT)/2);
8.92 + Image image = Utilities.loadImage("org/netbeans/bluej/welcome/gradient.png"); // NOI18N
8.93 + for (int i = 0; i<xx; i+=GRADIENT_WIDTH) {
8.94 + if (i > (offset_x + TRANSPARENT_EDGE_WIDTH) && i< (offset_x + backgroundWidth() - GRADIENT_WIDTH - TRANSPARENT_EDGE_WIDTH)) {
8.95 + continue;
8.96 + }
8.97 + g2d.drawImage(image, i, (yy-GRADIENT_HEIGHT)/2, this);
8.98 + }
8.99 + g2d.setColor(BOT_COLOR);
8.100 + g2d.fillRect(0, (yy+GRADIENT_HEIGHT)/2, xx, yy);
8.101 +
8.102 +
8.103 + g.drawImage(background.getImage(), offset_x, offset_y, this);
8.104 +
8.105 + pc(jButton1, g);
8.106 + pc(jButton2, g);
8.107 + pc(jButton3, g);
8.108 + pc(jButton4, g);
8.109 + pc(jLabel3, g);
8.110 +
8.111 +// long end = System.currentTimeMillis();
8.112 +// System.err.println("Paint:" + (end - start) + "ms");
8.113 + }
8.114 +
8.115 + private void pc (JComponent jc, Graphics g) {
8.116 + int x = jc.getX();
8.117 + int y = jc.getY();
8.118 + g.translate (x, y);
8.119 + jc.paint(g);
8.120 + g.translate(-x, -y);
8.121 + }
8.122 +
8.123 + private int backgroundWidth() {
8.124 + if (backgroundWidth == -1) {
8.125 + backgroundWidth = background.getIconWidth();
8.126 + }
8.127 + return backgroundWidth;
8.128 + }
8.129 +
8.130 + private int backgroundHeight() {
8.131 + if (backgroundHeight == -1) {
8.132 + backgroundHeight = background.getIconHeight();
8.133 + }
8.134 + return backgroundHeight;
8.135 + }
8.136 +
8.137 + public void addNotify() {
8.138 + super.addNotify();
8.139 + //Get cursor lookup out of the way
8.140 + SwingUtilities.invokeLater(this);
8.141 + }
8.142 +
8.143 + public void run() {
8.144 + //XXX better to do this on a timer, but I can't override
8.145 + //actionPerformed() and I don't want to create another class
8.146 + Cursor cur = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
8.147 + jLabel3.setCursor(cur);
8.148 + jButton1.setCursor (cur);
8.149 + jButton2.setCursor(cur);
8.150 + jButton3.setCursor(cur);
8.151 + jButton4.setCursor(cur);
8.152 + }
8.153 + /**
8.154 + * Layout driven by background image.
8.155 + *
8.156 + * There is a horizontal line and two button groups:
8.157 + * <ul>
8.158 + * <li> two big buttons above the line
8.159 + * <li> four small buttons under the line
8.160 + * </ul>
8.161 + * The line position is constant and buttons
8.162 + * should expand out it. There are following boxes:
8.163 + *
8.164 + <pre>
8.165 +
8.166 + 1
8.167 +
8.168 + 222222
8.169 + 333333 222222
8.170 + ---------------------------------
8.171 + 444444
8.172 + 444444
8.173 + 444444
8.174 + 55 444444
8.175 +
8.176 +
8.177 +
8.178 + 1 is for Java logo: 44x26
8.179 + 2s are for big buttons: 22x200
8.180 + 3 is for product logo: 35x160
8.181 + 4s are small buttons: 18x200
8.182 + 5 is for Sun logo: 31x71
8.183 + --- stands for background golden "base" line
8.184 + </pre>
8.185 + */
8.186 +// private class TitleLayout implements LayoutManager {
8.187 + public void addLayoutComponent(String name, Component comp) {
8.188 + }
8.189 +
8.190 + public void removeLayoutComponent(Component comp) {
8.191 + }
8.192 +
8.193 + public Dimension preferredLayoutSize(Container parent) {
8.194 + return new Dimension(backgroundWidth(), backgroundHeight());
8.195 + }
8.196 +
8.197 + public Dimension minimumLayoutSize(Container parent) {
8.198 + return preferredLayoutSize(parent);
8.199 + }
8.200 +
8.201 + public void layoutContainer(Container parent) {
8.202 +
8.203 + int offset_x = (parent.getSize().width - backgroundWidth())/2;
8.204 + int offset_y = (parent.getSize().height - backgroundHeight())/2;
8.205 +
8.206 + int base_x = offset_x + BUTTONS_X_OFFSET;
8.207 + int base_y = offset_y + 287; // taken from background.png
8.208 + int SMALL_SPACE = 5;
8.209 + int NB_LOGO_ALIGN = 4;
8.210 + int BOT_GROUP_ALIGN = 16; // 12 is real align with Sun logo by Leos said that 16 is optical align
8.211 + int TOP_BUTTON_HEIGHT = 22;
8.212 + int BOT_BUTTON_HEIGHT = 18;
8.213 +
8.214 + int y = base_y;
8.215 + int w = maxWidth();
8.216 +
8.217 + y -= TOP_BUTTON_HEIGHT + SMALL_SPACE + NB_LOGO_ALIGN;
8.218 + jButton2.setLocation(base_x, y);
8.219 + resize(jButton2, w, TOP_BUTTON_HEIGHT);
8.220 +
8.221 + y -= TOP_BUTTON_HEIGHT + SMALL_SPACE;
8.222 + jButton1.setLocation(base_x, y);
8.223 + resize(jButton1, w, TOP_BUTTON_HEIGHT);
8.224 +
8.225 + // horizontal line = base_y
8.226 +
8.227 + y = base_y + SMALL_SPACE + BOT_GROUP_ALIGN;
8.228 + jButton3.setLocation(base_x, y);
8.229 + resize(jButton3, w, BOT_BUTTON_HEIGHT);
8.230 +
8.231 + y += BOT_BUTTON_HEIGHT + SMALL_SPACE;
8.232 + jButton4.setLocation(base_x, y);
8.233 + resize(jButton4, w, BOT_BUTTON_HEIGHT);
8.234 +
8.235 + // NB logo
8.236 + jLabel3.setSize(160, 35); // measured image size
8.237 + jLabel3.setLocation(50 + offset_x, 246 + offset_y);
8.238 +
8.239 + }
8.240 +
8.241 + private void resize(JComponent target, int width, int height) {
8.242 + target.setSize(width, height);
8.243 + }
8.244 +
8.245 + private int maxWidth() {
8.246 + return backgroundWidth() - BUTTONS_X_OFFSET - TRANSPARENT_EDGE_WIDTH; // 15pixels margin taken from measuring background.png
8.247 + }
8.248 +
8.249 +// }
8.250 +
8.251 +
8.252 + /** This method is called from within the constructor to
8.253 + * initialize the form.
8.254 + * WARNING: Do NOT modify this code. The content of this method is
8.255 + * always regenerated by the Form Editor.
8.256 + */
8.257 + // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
8.258 + private void initComponents() {
8.259 + jButton1 = new OvalButton();
8.260 + jButton2 = new OvalButton();
8.261 + jButton3 = new OvalButton();
8.262 + jButton4 = new OvalButton();
8.263 + jLabel3 = new javax.swing.JLabel();
8.264 +
8.265 + org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(TitlePanel50.class, "BK0001"));
8.266 + jButton1.setFocusable(false);
8.267 + jButton1.addActionListener(this);
8.268 +
8.269 + add(jButton1);
8.270 +
8.271 + org.openide.awt.Mnemonics.setLocalizedText(jButton2, org.openide.util.NbBundle.getMessage(TitlePanel50.class, "BK0002"));
8.272 + jButton2.setFocusable(false);
8.273 + jButton2.addActionListener(this);
8.274 +
8.275 + add(jButton2);
8.276 +
8.277 + org.openide.awt.Mnemonics.setLocalizedText(jButton3, org.openide.util.NbBundle.getMessage(TitlePanel50.class, "BK0003"));
8.278 + jButton3.setFocusable(false);
8.279 + jButton3.addActionListener(this);
8.280 +
8.281 + add(jButton3);
8.282 +
8.283 + org.openide.awt.Mnemonics.setLocalizedText(jButton4, org.openide.util.NbBundle.getMessage(TitlePanel50.class, "BK0004"));
8.284 + jButton4.setFocusable(false);
8.285 + jButton4.addActionListener(this);
8.286 +
8.287 + add(jButton4);
8.288 +
8.289 + jLabel3.addMouseListener(this);
8.290 +
8.291 + add(jLabel3);
8.292 +
8.293 + }
8.294 +
8.295 + // Code for dispatching events from components to event handlers.
8.296 +
8.297 + public void actionPerformed(java.awt.event.ActionEvent evt) {
8.298 + if (evt.getSource() == jButton1) {
8.299 + TitlePanel50.this.jButton1ActionPerformed(evt);
8.300 + }
8.301 + else if (evt.getSource() == jButton2) {
8.302 + TitlePanel50.this.jButton2ActionPerformed(evt);
8.303 + }
8.304 + else if (evt.getSource() == jButton3) {
8.305 + TitlePanel50.this.jButton3ActionPerformed(evt);
8.306 + }
8.307 + else if (evt.getSource() == jButton4) {
8.308 + TitlePanel50.this.jButton4ActionPerformed(evt);
8.309 + }
8.310 + }
8.311 +
8.312 + public void mouseClicked(java.awt.event.MouseEvent evt) {
8.313 + if (evt.getSource() == jLabel3) {
8.314 + TitlePanel50.this.jLabel3MouseClicked(evt);
8.315 + }
8.316 + }
8.317 +
8.318 + public void mouseEntered(java.awt.event.MouseEvent evt) {
8.319 + }
8.320 +
8.321 + public void mouseExited(java.awt.event.MouseEvent evt) {
8.322 + }
8.323 +
8.324 + public void mousePressed(java.awt.event.MouseEvent evt) {
8.325 + }
8.326 +
8.327 + public void mouseReleased(java.awt.event.MouseEvent evt) {
8.328 + }// </editor-fold>//GEN-END:initComponents
8.329 +
8.330 + private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel3MouseClicked
8.331 + BusinessLogic.perform(103, this);
8.332 + }//GEN-LAST:event_jLabel3MouseClicked
8.333 +
8.334 + private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
8.335 + BusinessLogic.perform(4, this);
8.336 + }//GEN-LAST:event_jButton4ActionPerformed
8.337 +
8.338 + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
8.339 + BusinessLogic.perform(3, this);
8.340 + }//GEN-LAST:event_jButton3ActionPerformed
8.341 +
8.342 + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
8.343 + BusinessLogic.perform(2, this);
8.344 + }//GEN-LAST:event_jButton2ActionPerformed
8.345 +
8.346 + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
8.347 + BusinessLogic.perform(1, this);
8.348 + }//GEN-LAST:event_jButton1ActionPerformed
8.349 +
8.350 +
8.351 + // Variables declaration - do not modify//GEN-BEGIN:variables
8.352 + private javax.swing.JButton jButton1;
8.353 + private javax.swing.JButton jButton2;
8.354 + private javax.swing.JButton jButton3;
8.355 + private javax.swing.JButton jButton4;
8.356 + private javax.swing.JLabel jLabel3;
8.357 + // End of variables declaration//GEN-END:variables
8.358 +
8.359 +}