|
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.autoupdate; import java.awt.Font; import javax.swing.*; import org.openide.DialogDescriptor; import org.openide.DialogDisplayer; import org.openide.util.NbBundle; class ConnectingErrorDialog extends javax.swing.JPanel { /** Type of the dialog */ private static int type; private static String serverMessage; private javax.swing.JLabel titleLabel; private javax.swing.JTextArea textArea; private javax.swing.JLabel iconLabel; /** Creates new form ConnectingDialog */ public ConnectingErrorDialog() { initComponents(); initAccessibility(); setPreferredSize(new java.awt.Dimension(350,120)); } /** This method is called from within the constructor to * initialize the form. */ private void initComponents() { iconLabel = new javax.swing.JLabel(); titleLabel = new javax.swing.JLabel(); textArea = new javax.swing.JTextArea(); setLayout(new java.awt.GridBagLayout()); java.awt.GridBagConstraints gridBagConstraints; iconLabel.setIcon(getIcon (type)); // NOI18N titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD)); titleLabel.setForeground(java.awt.Color.black); if (type == Updates.NO_NETWORK) titleLabel.setText(getBundle("CTL_NoNetwork_titleLabel")); else if (type == Updates.NO_SERVER_ERROR) titleLabel.setText(getBundle("CTL_NoServer_titleLabel")); else if (type == Updates.NO_AVAILABLE_MODULES) titleLabel.setText(getBundle("CTL_NoAvailableModules_titleLabel")); else if (type == Updates.PARSE_ERROR) titleLabel.setText(getBundle("CTL_ParseError_titleLabel")); else titleLabel.setText(getBundle("CTL_Invalid_titleLabel")); textArea.setFont(new Font ("Dialog", Font.PLAIN, textArea.getFont().getSize())); // NOI18N textArea.setBackground( titleLabel.getBackground() ); textArea.setDisabledTextColor(java.awt.Color.black); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setEnabled(false); if ( type == Updates.NO_NETWORK && serverMessage != null ) textArea.setText( serverMessage ); else { if (type == Updates.NO_NETWORK) { textArea.setText(getBundle("CTL_NoNetwork_textLabel")); } else if (type == Updates.NO_SERVER_ERROR) { textArea.setText(getBundle("CTL_NoServer_textLabel")); } else if (type == Updates.NO_AVAILABLE_MODULES) { if (serverMessage == null) serverMessage = getBundle ("CTL_DefaultServer"); textArea.setText(NbBundle.getMessage (ConnectingErrorDialog.class, "CTL_NoAvailableModules_textLabel", serverMessage)); } else if (type == Updates.PARSE_ERROR) { textArea.setText(getBundle("CTL_ParseError_textLabel")); } else { textArea.setText(getBundle("CTL_Invalid_textLabel")); } } gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridheight = 0; gridBagConstraints.insets = new java.awt.Insets(18, 18, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; add(iconLabel, gridBagConstraints); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 1; gridBagConstraints.gridwidth = 0; gridBagConstraints.insets = new java.awt.Insets(18, 12, 0, 18); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weighty = 0.0; add(titleLabel, gridBagConstraints); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 0; gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 18); gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(textArea, gridBagConstraints); } private void initAccessibility(){ getAccessibleContext().setAccessibleDescription(getBundle("ACSD_ConnError")); getAccessibleContext().setAccessibleName (getDialogTitle (type)); } static private String getDialogTitle (int errorType) { switch (errorType) { case Updates.NO_AVAILABLE_MODULES: return getBundle ("CTL_Warning"); case Updates.NO_SERVER_ERROR: return getBundle ("CTL_Warning"); default: return getBundle ("CTL_Error"); } } static private Icon getIcon (int errorType) { switch (errorType) { case Updates.NO_AVAILABLE_MODULES: return javax.swing.UIManager.getIcon("OptionPane.warningIcon"); case Updates.NO_SERVER_ERROR: return javax.swing.UIManager.getIcon("OptionPane.warningIcon"); default: return javax.swing.UIManager.getIcon("OptionPane.errorIcon"); } } private static DialogDescriptor createDialog() { final JButton okButton = new JButton(getBundle( "CTL_Error_OK" ) ); // bugfix #40917, mnemonic on default OK button is useless //okButton.setMnemonic(getBundle( "ACS_Error_OK_mnc" ).charAt(0) ); okButton.getAccessibleContext().setAccessibleDescription(getBundle( "ACSD_Error_OK" ) ); DialogDescriptor dd; dd = new DialogDescriptor( new ConnectingErrorDialog(), getDialogTitle (type), true, // Modal new Object [] { okButton, }, // Option list okButton, // Default DialogDescriptor.DEFAULT_ALIGN, // Align null, //new HelpCtx ( ConnectingErrorDialog.class ), // Help new java.awt.event.ActionListener() { public void actionPerformed( java.awt.event.ActionEvent evt ) { } }); dd.setClosingOptions( null ); return dd; } static void showDialog(int type, String serverMessage) { ConnectingErrorDialog.type = type; ConnectingErrorDialog.serverMessage = serverMessage; DialogDescriptor dd = createDialog(); java.awt.Dialog dialog = DialogDisplayer.getDefault().createDialog( dd ); dialog.show(); dialog.dispose(); } private static String getBundle( String key ) { return NbBundle.getMessage( ConnectingErrorDialog.class, key ); } } |
... 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.