💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
绘制进度条,login页面 Index.java ~~~ package cy.view; import java.awt.*; import javax.swing.*; public class Index extends JWindow implements Runnable { JProgressBar jpb;//绘制进度条 JLabel jl1; int width,height; public static void main(String[] args) { Index index=new Index(); Thread t=new Thread(index);//启动线程-进度条 t.start(); } public Index() { jl1=new JLabel(new ImageIcon("image/index.gif")); jpb=new JProgressBar(); jpb.setStringPainted(true); jpb.setIndeterminate(false); jpb.setBorderPainted(false); jpb.setBackground(Color.darkGray); this.add(jl1,BorderLayout.NORTH); this.add(jpb,BorderLayout.SOUTH); this.setSize(400,263); width=Toolkit.getDefaultToolkit().getScreenSize().width; height=Toolkit.getDefaultToolkit().getScreenSize().height; this.setLocation(width/2-200,height/2-150); this.setVisible(true); } @Override public void run() { int []progressValue={0,1,5,8,14,17,26,35,38,43,49,56,65,71,75,78,86,94,98,99,100}; for(int i=0;i<progressValue.length;i++) { try { Thread.sleep(1000); } catch (Exception e) {} jpb.setValue(progressValue[i]); } } } ~~~ Login.java ~~~ package cy.view; import javax.imageio.*; import javax.swing.*; import javax.swing.border.*; //import zidingyi.*; import java.awt.*; import java.awt.event.*; import java.io.*; //import cy.moxing.*; public class Login extends JDialog /*implements ActionListener*/ { JLabel jl1,jl2,jl3;//标签 JTextField jname;//文本框 JPasswordField jpasswd;//密码框 JButton jlog,jcancle;//按钮 Font f1; public static void main(String []args) { Login login=new Login(); } public Login() { jl1=new JLabel("请输入用户名:"); jl1.setBounds(60, 190, 150, 30); //jl1.setFont(MyFont.f1); this.add(jl1); jl2=new JLabel("(或员工号)"); jl2.setForeground(Color.red); //jl2.setFont(MyFont.f2); jl2.setBounds(100,210,100,30); this.add(jl2); jl3=new JLabel ("请输入密码:"); jl3.setBounds(60,240,150,30); //jl3.setFont(MyFont.f2); this.add(jl3); jname=new JTextField(20); jname.setFocusable(true);//光标默认在这儿 jname.setBounds(180,190,120,30); jname.setFont(f1); this.add(jname); jname.setBorder(BorderFactory.createLoweredBevelBorder()); jpasswd=new JPasswordField(); jpasswd.setFocusable(true); jpasswd.setBounds(180,240,120,30); this.add(jpasswd); jpasswd.setBorder(BorderFactory.createLoweredBevelBorder()); jlog=new JButton("确 定"); //jlog.addActionListener(this); jlog.setBounds(105,300,75,30); jlog.setFont(f1); jlog.setForeground(Color.blue); this.add(jlog); jcancle=new JButton("取 消"); //jcancle.addActionListener(this); jcancle.setBounds(215,300,75,30); jcancle.setFont(f1); jcancle.setForeground(Color.blue); this.add(jcancle); this.setLayout(null); BackImage bi=new BackImage(); bi.setBounds(0,0,360,360); this.add(bi); this.setUndecorated(true); this.setSize(360, 360); int width=getToolkit().getDefaultToolkit().getScreenSize().width; int height=getToolkit().getDefaultToolkit().getScreenSize().height; this.setLocation(width/2-200,height/2-200); this.setVisible(true); } /* public void actionPerformed(ActionEvent e) { if(e.getSource()==jlog) { // String userName=this.jname.getText().trim(); // String passwd=new String(this.jpasswd.getPassword()); // Moxing um=new Moxing(); // String zhiwei=um.checkUser(userName, passwd); // if(zhiwei.equals("经理")||zhiwei.equals("管理员")||zhiwei.equals("主管")) { new Caozuo(); this.dispose(); } // else // { // JOptionPane.showMessageDialog(this,"用户名或密码错误"); // } } else if(e.getSource()==jcancle) { this.dispose(); } } */ } class BackImage extends JPanel { Image im; public BackImage() { try { im=ImageIO.read(new File("image/login.gif")); } catch(Exception e){} } public void paint(Graphics g) { g.drawImage(im,0,0,360,360,this); } } ~~~ ![](https://box.kancloud.cn/b752a76b7499fe3c6de0c60e5cca87a2_400x262.png) ![](https://box.kancloud.cn/41862a98d12e29982d3a9a63d3fac716_362x360.png)