基于netbeans的java桌面应用程序合集

源代码在线查看: add.java

软件大小: 4459 K
上传用户: zhongcheng211
关键词: netbeans java 应用程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*
				 * Add.java
				 *
				 * Created on 2007年10月15日, 下午10:03
				 */
				
				package org.Adam;
				
				import java.util.Vector;
				
				/**
				 *
				 * @author  Administrator
				 */
				public class Add extends javax.swing.JFrame {
				    Vector image=new Vector();
				    /** Creates new form Add */
				    public Add() {
				        
				        initComponents();
				        this.setLocationRelativeTo(this);
				        this.setTitle("asd");
				    }
				    
				    /** 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.
				     */
				    // //GEN-BEGIN:initComponents
				    private void initComponents() {
				        jScrollPane1 = new javax.swing.JScrollPane();
				        jList1 = new javax.swing.JList();
				        jTextField1 = new javax.swing.JTextField();
				        jButton1 = new javax.swing.JButton();
				        jButton2 = new javax.swing.JButton();
				
				        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
				        jScrollPane1.setViewportView(jList1);
				
				        jButton1.setText("Add");
				        jButton1.addActionListener(new java.awt.event.ActionListener() {
				            public void actionPerformed(java.awt.event.ActionEvent evt) {
				                jButton1ActionPerformed(evt);
				            }
				        });
				
				        jButton2.setText("Delete");
				        jButton2.addActionListener(new java.awt.event.ActionListener() {
				            public void actionPerformed(java.awt.event.ActionEvent evt) {
				                jButton2ActionPerformed(evt);
				            }
				        });
				
				        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
				        getContentPane().setLayout(layout);
				        layout.setHorizontalGroup(
				            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
				                .add(20, 20, 20)
				                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 74, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
				                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 73, Short.MAX_VALUE)
				                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				                    .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 69, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
				                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jButton2))
				                .add(77, 77, 77))
				            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
				                .addContainerGap(143, Short.MAX_VALUE)
				                .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 109, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
				                .add(61, 61, 61))
				        );
				        layout.setVerticalGroup(
				            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				            .add(layout.createSequentialGroup()
				                .add(52, 52, 52)
				                .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
				                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
				                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				                    .add(layout.createSequentialGroup()
				                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
				                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
				                    .add(layout.createSequentialGroup()
				                        .add(34, 34, 34)
				                        .add(jButton1)
				                        .add(43, 43, 43)
				                        .add(jButton2)))
				                .addContainerGap(160, Short.MAX_VALUE))
				        );
				        pack();
				    }// //GEN-END:initComponents
				
				    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
				// TODO 将在此处添加您的处理代码:
				        String Remove=(String) this.jList1.getSelectedValue();
				        this.image.remove(Remove);
				        this.jList1.setListData(image);
				    }//GEN-LAST:event_jButton2ActionPerformed
				
				    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
				// TODO 将在此处添加您的处理代码:
				        String Country=this.jTextField1.getText();
				        this.image.add(Country);
				        this.jList1.setListData(image);
				    }//GEN-LAST:event_jButton1ActionPerformed
				    
				    /**
				     * @param args the command line arguments
				     */
				    public static void main(String args[]) {
				        java.awt.EventQueue.invokeLater(new Runnable() {
				            public void run() {
				                new Add().setVisible(true);
				            }
				        });
				    }
				    
				    // 变量声明 - 不进行修改//GEN-BEGIN:variables
				    private javax.swing.JButton jButton1;
				    private javax.swing.JButton jButton2;
				    private javax.swing.JList jList1;
				    private javax.swing.JScrollPane jScrollPane1;
				    private javax.swing.JTextField jTextField1;
				    // 变量声明结束//GEN-END:variables
				    
				}
							

相关资源