Вы находитесь на странице: 1из 6

package newarty; import import import import import javax.swing.JFrame; org.jdesktop.application.Application; org.jdesktop.application.SingleFrameApplication; org.jvnet.substance.SubstanceLookAndFeel; org.jvnet.substance.watermark.

SubstanceImageWatermark;

/** * The main class of the application. */ public class NewArtyApp extends SingleFrameApplication { /** * At startup create and show the main frame of the application. */ @Override protected void startup() { JFrame.setDefaultLookAndFeelDecorated(true); jf_compras.setDefaultLookAndFeelDecorated(true); jf_ventas.setDefaultLookAndFeelDecorated(true); SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin.MistAquaSkin"); SubstanceLookAndFeel.setCurrentTheme("org.jvnet.substance.theme.Substanc eBlendBiTheme"); SubstanceLookAndFeel.setCurrentWatermark(new SubstanceImageWatermark("lo godragon.png")); SubstanceLookAndFeel.setImageWatermarkOpacity(new Float(0.7)); show(new NewArtyView(this));

package desktopapplication5; import import import import import import import import import org.jdesktop.application.Action; org.jdesktop.application.ResourceMap; org.jdesktop.application.SingleFrameApplication; org.jdesktop.application.FrameView; org.jdesktop.application.TaskMonitor; java.awt.event.ActionEvent; java.awt.event.ActionListener; javax.swing.Timer; javax.swing.Icon;

import javax.swing.JDialog; import javax.swing.JFrame; import org.jvnet.substance.SubstanceLookAndFeel; /** * The application's main frame. */ public class DesktopApplication5View extends FrameView { public DesktopApplication5View(SingleFrameApplication app) { super(app); initComponents(); this.jButton1.putClientProperty(SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY , new StandarButtonShaper()); // status bar initialization - message timeout, idle icon and busy anima tion, etc ResourceMap resourceMap = getResourceMap(); int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout"); messageTimer = new Timer(messageTimeout, new ActionListener() { public void actionPerformed(ActionEvent e) { statusMessageLabel.setText(""); } }); messageTimer.setRepeats(false); int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationR ate"); for (int i = 0; i < busyIcons.length; i++) { busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]") ; } busyIconTimer = new Timer(busyAnimationRate, new ActionListener() { public void actionPerformed(ActionEvent e) { busyIconIndex = (busyIconIndex + 1) % busyIcons.length; statusAnimationLabel.setIcon(busyIcons[busyIconIndex]); } }); idleIcon = resourceMap.getIcon("StatusBar.idleIcon"); statusAnimationLabel.setIcon(idleIcon); progressBar.setVisible(false); // connecting action tasks to status bar via TaskMonitor TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext()) ; taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListe ner() { public void propertyChange(java.beans.PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if ("started".equals(propertyName)) { if (!busyIconTimer.isRunning()) { statusAnimationLabel.setIcon(busyIcons[0]); busyIconIndex = 0; busyIconTimer.start(); } progressBar.setVisible(true); progressBar.setIndeterminate(true); } else if ("done".equals(propertyName)) { busyIconTimer.stop();

statusAnimationLabel.setIcon(idleIcon); progressBar.setVisible(false); progressBar.setValue(0); } else if ("message".equals(propertyName)) { String text = (String)(evt.getNewValue()); statusMessageLabel.setText((text == null) ? "" : text); messageTimer.restart(); } else if ("progress".equals(propertyName)) { int value = (Integer)(evt.getNewValue()); progressBar.setVisible(true); progressBar.setIndeterminate(false); progressBar.setValue(value); } } }); } @Action public void showAboutBox() { if (aboutBox == null) { JFrame mainFrame = DesktopApplication5.getApplication().getMainFrame (); aboutBox = new DesktopApplication5AboutBox(mainFrame); aboutBox.setLocationRelativeTo(mainFrame); } DesktopApplication5.getApplication().show(aboutBox); } /** 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. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { mainPanel = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); menuBar = new javax.swing.JMenuBar(); javax.swing.JMenu fileMenu = new javax.swing.JMenu(); javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem(); javax.swing.JMenu helpMenu = new javax.swing.JMenu(); javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem(); statusPanel = new javax.swing.JPanel(); javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator (); statusMessageLabel = new javax.swing.JLabel(); statusAnimationLabel = new javax.swing.JLabel(); progressBar = new javax.swing.JProgressBar(); mainPanel.setName("mainPanel"); // NOI18N org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.applicat ion.Application.getInstance(desktopapplication5.DesktopApplication5.class).getCo ntext().getResourceMap(DesktopApplication5View.class); jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N jButton1.setName("jButton1"); // NOI18N

jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N jButton2.setName("jButton2"); // NOI18N javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(ma inPanel); mainPanel.setLayout(mainPanelLayout); mainPanelLayout.setHorizontalGroup( mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignmen t.LEADING) .addGroup(mainPanelLayout.createSequentialGroup() .addGap(70, 70, 70) .addComponent(jButton1) .addContainerGap(257, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayou t.createSequentialGroup() .addContainerGap(225, Short.MAX_VALUE) .addComponent(jButton2) .addGap(102, 102, 102)) ); mainPanelLayout.setVerticalGroup( mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignmen t.LEADING) .addGroup(mainPanelLayout.createSequentialGroup() .addGap(77, 77, 77) .addComponent(jButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA TED, 66, Short.MAX_VALUE) .addComponent(jButton2) .addGap(63, 63, 63)) ); menuBar.setName("menuBar"); // NOI18N fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N fileMenu.setName("fileMenu"); // NOI18N javax.swing.ActionMap actionMap = org.jdesktop.application.Application.g etInstance(desktopapplication5.DesktopApplication5.class).getContext().getAction Map(DesktopApplication5View.class, this); exitMenuItem.setAction(actionMap.get("quit")); // NOI18N exitMenuItem.setName("exitMenuItem"); // NOI18N fileMenu.add(exitMenuItem); menuBar.add(fileMenu); helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N helpMenu.setName("helpMenu"); // NOI18N aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N aboutMenuItem.setName("aboutMenuItem"); // NOI18N helpMenu.add(aboutMenuItem); menuBar.add(helpMenu); statusPanel.setName("statusPanel"); // NOI18N statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N statusMessageLabel.setName("statusMessageLabel"); // NOI18N

statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.L EFT); statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N progressBar.setName("progressBar"); // NOI18N javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout( statusPanel); statusPanel.setLayout(statusPanelLayout); statusPanelLayout.setHorizontalGroup( statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_ SIZE, 400, Short.MAX_VALUE) .addGroup(statusPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(statusMessageLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA TED, 230, Short.MAX_VALUE) .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZ E, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA TED) .addComponent(statusAnimationLabel) .addContainerGap()) ); statusPanelLayout.setVerticalGroup( statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addGroup(statusPanelLayout.createSequentialGroup() .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREF ERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELA TED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(statusPanelLayout.createParallelGroup(javax.swing.Grou pLayout.Alignment.BASELINE) .addComponent(statusMessageLabel) .addComponent(statusAnimationLabel) .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED _SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_S IZE)) .addGap(3, 3, 3)) ); setComponent(mainPanel); setMenuBar(menuBar); setStatusBar(statusPanel); }// </editor-fold> // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JPanel mainPanel; private javax.swing.JMenuBar menuBar; private javax.swing.JProgressBar progressBar; private javax.swing.JLabel statusAnimationLabel; private javax.swing.JLabel statusMessageLabel; private javax.swing.JPanel statusPanel; // End of variables declaration

private private private private private }

final Timer messageTimer; final Timer busyIconTimer; final Icon idleIcon; final Icon[] busyIcons = new Icon[15]; int busyIconIndex = 0;

private JDialog aboutBox;

Вам также может понравиться