一个有趣Java小案例,练练手,目前还是初级版本,还在升级当中哦…(附实现代码在下面) 实现的代码在这 我是一颗剽悍的种子(一颗偏爱前端的后端新司机) 老板,可不要忘了、和关注哟~
老板,这是你要拨打的电话吗?
import java.awt.BorderLayout; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import javax.swing.JButton; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Random; import java.awt.event.ActionEvent; import java.awt.FlowLayout; import com.jgoodies.forms.layout.FormLayout; import com.jgoodies.forms.layout.ColumnSpec; import com.jgoodies.forms.layout.FormSpecs; import com.jgoodies.forms.layout.RowSpec; import javax.swing.JLabel; import java.awt.GridLayout; import java.awt.CardLayout; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.JLayeredPane; import javax.swing.JTextField; import java.awt.Font; public class Dial extends JFrame { /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Dial frame = new Dial(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public Dial() { setTitle("u62E8u53F7"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 496, 300); getContentPane().setLayout(null); JLayeredPane layeredPane = new JLayeredPane(); layeredPane.setBounds(89, 117, 1, 1); getContentPane().add(layeredPane); JButton btnNewButton = new JButton("u662F"); btnNewButton.setBounds(22, 142, 83, 48); getContentPane().add(btnNewButton); JLabel lblNewLabel = new JLabel("u8FD9u662Fu4F60u8981u62E8u6253u7684u7535u8BDDu5417uFF1F"); lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20)); lblNewLabel.setBounds(23, 69, 219, 63); getContentPane().add(lblNewLabel); JLabel lblNewLabel_1 = new JLabel(radomPhone()); lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 21)); lblNewLabel_1.setBounds(252, 85, 199, 28); getContentPane().add(lblNewLabel_1); JButton btnNewButton_1 = new JButton("u4E0Du662F"); btnNewButton_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //将随机手机号码给标签 lblNewLabel_1.setText(radomPhone()); } }); btnNewButton_1.setBounds(115, 142, 83, 48); getContentPane().add(btnNewButton_1); } //抽取11位随机数的手机号码 public String radomPhone() { Random r = new Random(); String text = ""; for(int i = 0;i<11;i++) { //随机数位数由循环决定,而随机的数字大小由r.nextInt决定 text += r.nextInt(10); } return text; } }
最近打算做——“破公司上班的最后一天,老板让我给他开发一个拨号程序”这一个系列,想让学Java路上也能好玩和有趣!
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算