📄 desktopapplication1view.java
字号:
/* * DesktopApplication1View.java */package desktopapplication1;import org.jdesktop.application.Action;import org.jdesktop.application.ResourceMap;import org.jdesktop.application.SingleFrameApplication;import org.jdesktop.application.FrameView;import org.jdesktop.application.TaskMonitor;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.Timer;import javax.swing.Icon;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JOptionPane;/** * The application's main frame. */public class DesktopApplication1View extends FrameView { public DesktopApplication1View(SingleFrameApplication app) { super(app); initComponents(); // status bar initialization - message timeout, idle icon and busy animation, 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.busyAnimationRate"); 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); // connecting action tasks to status bar via TaskMonitor TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext()); taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() { 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(); } } else if ("done".equals(propertyName)) { busyIconTimer.stop(); statusAnimationLabel.setIcon(idleIcon); } 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()); } } }); } @Action public void showAboutBox() { if (aboutBox == null) { JFrame mainFrame = DesktopApplication1.getApplication().getMainFrame(); aboutBox = new DesktopApplication1AboutBox(mainFrame); aboutBox.setLocationRelativeTo(mainFrame); } DesktopApplication1.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">//GEN-BEGIN:initComponents private void initComponents() { mainPanel = new javax.swing.JPanel(); textField1 = new java.awt.TextField(); label1 = new java.awt.Label(); label2 = new java.awt.Label(); label3 = new java.awt.Label(); button1 = new java.awt.Button(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); label4 = new java.awt.Label(); textField2 = new java.awt.TextField(); 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(); mainPanel.setName("mainPanel"); // NOI18N textField1.setName("textField1"); // NOI18N org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(desktopapplication1.DesktopApplication1.class).getContext().getResourceMap(DesktopApplication1View.class); textField1.setText(resourceMap.getString("textField1.text")); // NOI18N label1.setName("label1"); // NOI18N label1.setText(resourceMap.getString("label1.text")); // NOI18N label2.setName("label2"); // NOI18N label2.setText(resourceMap.getString("label2.text")); // NOI18N label3.setForeground(resourceMap.getColor("label3.foreground")); // NOI18N label3.setName("label3"); // NOI18N label3.setText(resourceMap.getString("label3.text")); // NOI18N button1.setActionCommand(resourceMap.getString("button1.actionCommand")); // NOI18N button1.setLabel(resourceMap.getString("button1.label")); // NOI18N button1.setName("button1"); // NOI18N button1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button1(evt); } }); jScrollPane1.setName("jScrollPane1"); // NOI18N jTable1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {" >500", new Double(0.05)}, {" 500~2000", new Double(0.1)}, {" 2000~5000", new Double(0.15)}, {" 5000~20000", new Double(0.2)}, {" >20000", new Double(0.25)} }, new String [] { " 应纳税所得额", " 税率" } ) { Class[] types = new Class [] { java.lang.Object.class, java.lang.Double.class }; boolean[] canEdit = new boolean [] { false, true }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); jTable1.setToolTipText(resourceMap.getString("jTable1.toolTipText")); // NOI18N jTable1.setName("jTable1"); // NOI18N jScrollPane1.setViewportView(jTable1); label4.setName("label4"); // NOI18N label4.setText(resourceMap.getString("label4.text")); // NOI18N textField2.setName("textField2"); // NOI18N textField2.setText(resourceMap.getString("textField2.text")); // NOI18N javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -