|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.welcome.ui; import java.awt.event.ActionEvent; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.net.URL; import java.util.Hashtable; import org.openide.ErrorManager; import org.openide.awt.HtmlBrowser; import org.openide.util.NbBundle; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; import org.openide.filesystems.Repository; import org.openide.cookies.InstanceCookie; import javax.swing.Action; import java.awt.*; import javax.swing.Box; import javax.swing.JPanel; /** * * @author or141057 */ public class TitlePanel extends javax.swing.JPanel { private static final String NEW_PROJECT_ACTION = "Actions/Project/org-netbeans-modules-project-ui-NewProject.instance"; private static final String OPEN_SAMPLE_ACTION = "org-netbeans-modules-project-ui-WelcomeScreenHack/org-netbeans-modules-project-ui-NewSample.instance"; private HtmlBrowser.URLDisplayer displayer = HtmlBrowser.URLDisplayer.getDefault(); private Hashtable recognized = new Hashtable(); /** Creates new form TitlePanel */ public TitlePanel() { initComponents(); myInitComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents java.awt.GridBagConstraints gridBagConstraints; jPanel2 = new javax.swing.JPanel(); thePanel = new javax.swing.JPanel(); image = new javax.swing.JLabel(); /* controls = new javax.swing.JPanel(); */ controls = new GradientPanel(0x00065f, 0x000334); /* newProjectsButton = new javax.swing.JButton(); */ newProjectsButton = new OvalButton(0x00043d, 0x5d4fff, 0xeeeeee, 0x766bff, 0x362e94, 0x766bff); /* openSampleButton = new javax.swing.JButton(); */ openSampleButton = new OvalButton(0x00043d, 0x5d4fff, 0xeeeeee, 0x766bff, 0x362e94, 0x766bff); /* quickStartGuideButton = new javax.swing.JButton(); */ quickStartGuideButton = new OvalButton(0x00043d,0x305899, 0xeeeeee, 0x2f5e99, 0x1b3759, 0x5077a9); /* j2seImportButton = new javax.swing.JButton(); */ j2seImportButton = new OvalButton(0x00043d, 0x305899, 0xeeeeee, 0x2f5e99, 0x1b3759, 0x5077a9); /* webImportButton = new javax.swing.JButton(); */ webImportButton = new OvalButton(0x00043d, 0x305899, 0xeeeeee, 0x2f5e99, 0x1b3759, 0x5077a9); /* returningUserButton = new javax.swing.JButton(); */ returningUserButton = new OvalButton(0x00043d, 0x305899, 0xeeeeee, 0x2f5e99, 0x1b3759, 0x5077a9); /* j2meSupportButton = new javax.swing.JButton(); */ j2meSupportButton = new OvalButton(0x00043d,0x305899, 0xeeeeee, 0x2f5e99, 0x1b3759, 0x5077a9); /* productInformation = new javax.swing.JButton(); */ productInformation = new OvalButton(0x00043d, 0x305899, 0xeeeeee, 0x2f5e99, 0x1b3759, 0x5077a9); jPanel1 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS)); setBackground(new java.awt.Color(0, 0, 129)); setFocusCycleRoot(true); setPreferredSize(new java.awt.Dimension(660, 560)); addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { formFocusGained(evt); } }); jPanel2.setBackground(new java.awt.Color(255, 255, 255)); jPanel2.setEnabled(false); jPanel2.setFocusable(false); jPanel2.setMinimumSize(new java.awt.Dimension(0, 0)); jPanel2.setOpaque(false); jPanel2.setPreferredSize(new java.awt.Dimension(32767, 32767)); jPanel2.setRequestFocusEnabled(false); add(jPanel2); thePanel.setLayout(new javax.swing.BoxLayout(thePanel, javax.swing.BoxLayout.Y_AXIS)); thePanel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(128, 129, 154))); thePanel.setMaximumSize(new java.awt.Dimension(662, 562)); thePanel.setMinimumSize(new java.awt.Dimension(662, 562)); thePanel.setOpaque(false); thePanel.setPreferredSize(new java.awt.Dimension(662, 562)); image.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); image.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/welcome/ui/upper-image.png"))); image.setAlignmentX(0.5F); thePanel.add(image); controls.setLayout(new java.awt.GridBagLayout()); controls.setBackground(new java.awt.Color(0, 3, 61)); controls.setMaximumSize(new java.awt.Dimension(662, 203)); controls.setMinimumSize(new java.awt.Dimension(662, 203)); controls.setPreferredSize(new java.awt.Dimension(662, 203)); newProjectsButton.setBackground(new java.awt.Color(233, 235, 247)); newProjectsButton.setForeground(new java.awt.Color(0, 61, 116)); newProjectsButton.setText(org.openide.util.NbBundle.getMessage(TitlePanel.class, "BTN_NEW_PROJECT")); newProjectsButton.setAlignmentX(0.5F); newProjectsButton.setBorder(new javax.swing.border.EtchedBorder(new java.awt.Color(211, 204, 204), new java.awt.Color(0, 61, 116))); newProjectsButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); newProjectsButton.setMaximumSize(new java.awt.Dimension(234, 26)); newProjectsButton.setMinimumSize(new java.awt.Dimension(234, 26)); newProjectsButton.setNextFocusableComponent(openSampleButton); newProjectsButton.setPreferredSize(new java.awt.Dimension(234, 26)); newProjectsButton.setRolloverEnabled(true); newProjectsButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { newProjectsButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(26, 0, 20, 6); controls.add(newProjectsButton, gridBagConstraints); openSampleButton.setBackground(new java.awt.Color(233, 235, 247)); openSampleButton.setForeground(new java.awt.Color(0, 61, 116)); openSampleButton.setText(org.openide.util.NbBundle.getMessage(TitlePanel.class, "BTN_SAMPLE_PROJECT")); openSampleButton.setAlignmentX(0.5F); openSampleButton.setBorder(new javax.swing.border.EtchedBorder(new java.awt.Color(211, 204, 204), new java.awt.Color(0, 61, 116))); openSampleButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); openSampleButton.setMaximumSize(new java.awt.Dimension(234, 26)); openSampleButton.setMinimumSize(new java.awt.Dimension(234, 26)); openSampleButton.setNextFocusableComponent(quickStartGuideButton); openSampleButton.setPreferredSize(new java.awt.Dimension(234, 26)); openSampleButton.setRolloverEnabled(true); openSampleButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { openSampleButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(26, 6, 20, 0); controls.add(openSampleButton, gridBagConstraints); quickStartGuideButton.setBackground(new java.awt.Color(50, 52, 98)); quickStartGuideButton.setFont(new java.awt.Font("Default", 0, 12)); quickStartGuideButton.setForeground(new java.awt.Color(233, 235, 247)); quickStartGuideButton.setText(org.openide.util.NbBundle.getMessage(TitlePanel.class, "BTN_QUICKSTART")); quickStartGuideButton.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1))); quickStartGuideButton.setBorderPainted(false); quickStartGuideButton.setContentAreaFilled(false); quickStartGuideButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); quickStartGuideButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); quickStartGuideButton.setMaximumSize(new java.awt.Dimension(234, 26)); quickStartGuideButton.setMinimumSize(new java.awt.Dimension(234, 26)); quickStartGuideButton.setNextFocusableComponent(returningUserButton); quickStartGuideButton.setPreferredSize(new java.awt.Dimension(234, 26)); quickStartGuideButton.setRolloverEnabled(true); quickStartGuideButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { quickStartGuideButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(2, 0, 1, 6); controls.add(quickStartGuideButton, gridBagConstraints); j2seImportButton.setBackground(new java.awt.Color(50, 52, 98)); j2seImportButton.setFont(new java.awt.Font("Default", 0, 12)); j2seImportButton.setForeground(new java.awt.Color(233, 235, 247)); j2seImportButton.setText(org.openide.util.NbBundle.getMessage(TitlePanel.class, "BTN_J2SE")); j2seImportButton.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1))); j2seImportButton.setBorderPainted(false); j2seImportButton.setContentAreaFilled(false); j2seImportButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); j2seImportButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); j2seImportButton.setMaximumSize(new java.awt.Dimension(234, 26)); j2seImportButton.setMinimumSize(new java.awt.Dimension(234, 26)); j2seImportButton.setNextFocusableComponent(j2meSupportButton); j2seImportButton.setPreferredSize(new java.awt.Dimension(234, 26)); j2seImportButton.setRolloverEnabled(true); j2seImportButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { j2seImportButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(2, 0, 1, 6); controls.add(j2seImportButton, gridBagConstraints); webImportButton.setBackground(new java.awt.Color(50, 52, 98)); webImportButton.setFont(new java.awt.Font("Default", 0, 12)); webImportButton.setForeground(new java.awt.Color(233, 235, 247)); webImportButton.setText(org.openide.util.NbBundle.getMessage(TitlePanel.class, "BTN_WEB")); webImportButton.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1))); webImportButton.setBorderPainted(false); webImportButton.setContentAreaFilled(false); webImportButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); webImportButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); webImportButton.setMaximumSize(new java.awt.Dimension(234, 26)); webImportButton.setMinimumSize(new java.awt.Dimension(234, 26)); webImportButton.setNextFocusableComponent(productInformation); webImportButton.setPreferredSize(new java.awt.Dimension(234, 26)); webImportButton.setRolloverEnabled(true); webImportButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { webImportButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(2, 0, 1, 6); controls.add(webImportButton, gridBagConstraints); returningUserButton.setBackground(new java.awt.Color(50, 52, 98)); returningUserButton.setFont(new java.awt.Font("Default", 0, 12)); returningUserButton.setForeground(new java.awt.Color(233, 235, 247)); returningUserButton.setText(org.openide.util.NbBundle.getMessage(TitlePanel.class, "BTN_RETURNING")); returningUserButton.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1))); returningUserButton.setBorderPainted(false); returningUserButton.setContentAreaFilled(false); returningUserButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); returningUserButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); returningUserButton.setMaximumSize(new java.awt.Dimension(234, 26)); returningUserButton.setMinimumSize(new java.awt.Dimension(234, 26)); returningUserButton.setNextFocusableComponent(j2seImportButton); returningUserButton.setPreferredSize(new java.awt.Dimension(234, 26)); returningUserButton.setRolloverEnabled(true); returningUserButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { returningUserButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(2, 6, 1, 0); controls.add(returningUserButton, gridBagConstraints); j2meSupportButton.setBackground(new java.awt.Color(50, 52, 98)); j2meSupportButton.setFont(new java.awt.Font("Default", 0, 12)); j2meSupportButton.setForeground(new java.awt.Color(233, 235, 247)); j2meSupportButton.setText(org.openide.util.NbBundle.getMessage(TitlePanel.class, "BTN_J2ME")); j2meSupportButton.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1))); j2meSupportButton.setBorderPainted(false); j2meSupportButton.setContentAreaFilled(false); j2meSupportButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); j2meSupportButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); j2meSupportButton.setMaximumSize(new java.awt.Dimension(234, 26)); j2meSupportButton.setMinimumSize(new java.awt.Dimension(234, 26)); j2meSupportButton.setNextFocusableComponent(webImportButton); j2meSupportButton.setPreferredSize(new java.awt.Dimension(234, 26)); j2meSupportButton.setRolloverEnabled(true); j2meSupportButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { j2meSupportButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(2, 6, 1, 0); controls.add(j2meSupportButton, gridBagConstraints); productInformation.setBackground(new java.awt.Color(50, 52, 98)); productInformation.setFont(new java.awt.Font("Default", 0, 12)); productInformation.setForeground(new java.awt.Color(233, 235, 247)); productInformation.setText(org.openide.util.NbBundle.getMessage(TitlePanel.class, "BTN_PRODUCT")); productInformation.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 1, 1, 1))); productInformation.setBorderPainted(false); productInformation.setContentAreaFilled(false); productInformation.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); productInformation.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); productInformation.setMaximumSize(new java.awt.Dimension(234, 26)); productInformation.setMinimumSize(new java.awt.Dimension(234, 26)); productInformation.setNextFocusableComponent(newProjectsButton); productInformation.setPreferredSize(new java.awt.Dimension(234, 26)); productInformation.setRolloverEnabled(true); productInformation.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { productInformationActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(2, 6, 1, 0); controls.add(productInformation, gridBagConstraints); jPanel1.setMinimumSize(new java.awt.Dimension(10, 45)); jPanel1.setOpaque(false); jPanel1.setPreferredSize(new java.awt.Dimension(10, 45)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; controls.add(jPanel1, gridBagConstraints); thePanel.add(controls); add(thePanel); jPanel3.setMinimumSize(new java.awt.Dimension(0, 0)); jPanel3.setOpaque(false); jPanel3.setPreferredSize(new java.awt.Dimension(32767, 32767)); add(jPanel3); }//GEN-END:initComponents private void myInitComponents() { /* Cursor cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); returningUserButton.setCursor(cursor); productInformation.setCursor(cursor); quickStartGuideButton.setCursor(cursor); j2meSupportButton.setCursor(cursor); j2seImportButton.setCursor(cursor); webImportButton.setCursor(cursor); */ } private void formFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_formFocusGained newProjectsButton.requestFocus(); }//GEN-LAST:event_formFocusGained private void openSampleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openSampleButtonActionPerformed performAction(OPEN_SAMPLE_ACTION); }//GEN-LAST:event_openSampleButtonActionPerformed private void productInformationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_productInformationActionPerformed showURL("HTML_PRODUCT"); }//GEN-LAST:event_productInformationActionPerformed private void j2meSupportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_j2meSupportButtonActionPerformed showURL("HTML_J2ME"); }//GEN-LAST:event_j2meSupportButtonActionPerformed private void returningUserButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_returningUserButtonActionPerformed showURL("HTML_RETURNING"); }//GEN-LAST:event_returningUserButtonActionPerformed private void webImportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_webImportButtonActionPerformed showURL("HTML_WEB"); }//GEN-LAST:event_webImportButtonActionPerformed private void j2seImportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_j2seImportButtonActionPerformed showURL("HTML_J2SE"); }//GEN-LAST:event_j2seImportButtonActionPerformed private void quickStartGuideButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quickStartGuideButtonActionPerformed showURL("HTML_QUICKSTART"); }//GEN-LAST:event_quickStartGuideButtonActionPerformed private void newProjectsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newProjectsButtonActionPerformed performAction(NEW_PROJECT_ACTION); }//GEN-LAST:event_newProjectsButtonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel controls; private javax.swing.JLabel image; private javax.swing.JButton j2meSupportButton; private javax.swing.JButton j2seImportButton; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JButton newProjectsButton; private javax.swing.JButton openSampleButton; private javax.swing.JButton productInformation; private javax.swing.JButton quickStartGuideButton; private javax.swing.JButton returningUserButton; private javax.swing.JPanel thePanel; private javax.swing.JButton webImportButton; // End of variables declaration//GEN-END:variables private URL getUrlFromFile(String page){ //short term solution just for a while FileOutputStream fout = null; if(recognized.containsKey(page)){ return (URL)recognized.get(page); } InputStream inp = getClass().getResourceAsStream("/org/netbeans/modules/welcome/pages/"+page); URL url; try{ File tmp = File.createTempFile(page,".html"); fout = new FileOutputStream(tmp); int c; while ((c = inp.read()) != -1) fout.write(c); inp.close(); fout.close(); url= tmp.toURL(); recognized.put(page, url); return url; }catch(Exception ex){ ErrorManager.getDefault().notify(ex); return null; }finally{ try{ inp.close(); fout.close(); }catch(Exception e){ // } } } private void showURL(String s) { URL url; try { url = new URL(NbBundle.getMessage(getClass(),s)); displayer.showURL(url); } catch (java.net.MalformedURLException ex) { ErrorManager.getDefault().notify(ex); } } private Action findAction (String key) { FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource(key); if (fo != null && fo.isValid()) { try { DataObject dob = DataObject.find (fo); InstanceCookie ic = (InstanceCookie) dob.getCookie(InstanceCookie.class); if (ic != null) { Object instance = ic.instanceCreate(); if (instance instanceof Action) { return (Action) instance; } } } catch (Exception e) { ErrorManager.getDefault().notify(ErrorManager.WARNING, e); return null; } } return null; } private boolean performAction (String key) { Action a = findAction (key); if (a == null) { return false; } ActionEvent ae = new ActionEvent (this, ActionEvent.ACTION_PERFORMED, "foo"); try { a.actionPerformed(ae); return true; } catch (Exception e) { ErrorManager.getDefault().notify(ErrorManager.WARNING, e); return false; } } /** * Overriden to paint gradient background */ protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D)g; // GradientPaint gp = new GradientPaint(0f, 210f, // new Color(0f,11/256f,157/256f), // 0f, // getHeight(), // new Color(0f, 1/256f, 40/256f), // true); // g2d.setPaint(gp); g2d.setPaint(new Color(0xECE9D8)); g2d.fillRect(0,0,getWidth(), getHeight()); } private static class GradientPanel extends JPanel { Color startColor, endColor; public GradientPanel(int sc, int ec) { super(); startColor = new Color(sc); endColor = new Color(ec); } /** * Overriden to paint gradient background */ protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D)g; GradientPaint gp = new GradientPaint(0f, 0f, startColor, 0f, getHeight(), endColor, true); g2d.setPaint(gp); g2d.fillRect(0,0,getWidth(), getHeight()); } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.