以set up方式安装使用自己写的java gui程序

本文介绍如何通过编写setup程序来实现批量安装exe文件的过程,包括创建setup程序、复制文件、修改文件名和路径等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、首先将写好的真正要使用的程序打成exe文件

2、然后写一个set up的程序也打成exe文件,这个exe文件要包括1步骤中的exe文件

3、set up程序的主要作用是将set up程序复制一份,然后改变后缀为zip文件,然后加压这个zip文件,最后将解压之后的程序依次复制到指定目录,就算安装完毕了。

4、进入安装目录,运行1步骤中的exe文件

下面是一个简单的Java电话号码查询的GUI程序示例: ```java import java.awt.*; import java.awt.event.*; import javax.swing.*; public class PhoneBookGUI extends JFrame implements ActionListener { private JTextField nameField, phoneField; private JButton addButton, searchButton; private JTextArea displayArea; private PhoneBook phoneBook; public PhoneBookGUI() { super("Phone Book"); // Create the phone book phoneBook = new PhoneBook(); // Set up the GUI components nameField = new JTextField(10); phoneField = new JTextField(10); addButton = new JButton("Add"); searchButton = new JButton("Search"); displayArea = new JTextArea(10, 20); // Add action listeners to the buttons addButton.addActionListener(this); searchButton.addActionListener(this); // Create the panel for the input fields and buttons JPanel inputPanel = new JPanel(); inputPanel.setLayout(new FlowLayout()); inputPanel.add(new JLabel("Name:")); inputPanel.add(nameField); inputPanel.add(new JLabel("Phone:")); inputPanel.add(phoneField); inputPanel.add(addButton); inputPanel.add(searchButton); // Create the panel for the display area JScrollPane scrollPane = new JScrollPane(displayArea); JPanel displayPanel = new JPanel(); displayPanel.setLayout(new BorderLayout()); displayPanel.add(scrollPane, BorderLayout.CENTER); // Add the panels to the content pane Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(inputPanel, BorderLayout.NORTH); contentPane.add(displayPanel, BorderLayout.CENTER); // Set the size and make the GUI visible setSize(300, 300); setVisible(true); } public void actionPerformed(ActionEvent e) { if (e.getSource() == addButton) { // Add a phone number to the phone book String name = nameField.getText(); String phone = phoneField.getText(); phoneBook.addPhoneNumber(name, phone); displayArea.setText("Phone number added."); nameField.setText(""); phoneField.setText(""); } else if (e.getSource() == searchButton) { // Search for a phone number in the phone book String name = nameField.getText(); String phone = phoneBook.getPhoneNumber(name); if (phone != null) { displayArea.setText("Phone number: " + phone); } else { displayArea.setText("Phone number not found."); } phoneField.setText(""); } } public static void main(String[] args) { PhoneBookGUI phoneBookGUI = new PhoneBookGUI(); phoneBookGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } class PhoneBook { private java.util.Map<String, String> phoneNumbers; public PhoneBook() { phoneNumbers = new java.util.HashMap<String, String>(); } public void addPhoneNumber(String name, String phone) { phoneNumbers.put(name, phone); } public String getPhoneNumber(String name) { return phoneNumbers.get(name); } } ``` 该程序有一个简单的GUI,包含两个文本框和两个按钮。用户可以输入一个人的姓名和电话号码,然后按下“Add”按钮将该信息添加到电话簿中。用户还可以输入一个人的姓名,并按下“Search”按钮来查找该人的电话号码。如果电话号码被找到,它将在文本区域中显示,否则将显示“Phone number not found.”。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值