D.Tech Academic
Deep Singh
Pages
Core Java
Web App
Spring
Hibernate
Kotlin
Android
Python
Flutter
Spring Boot
Splash File in java swing Tutorial
JWindow Example for making splash file
import java.awt.BorderLayout; import java.awt.Color; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JProgressBar; import javax.swing.JWindow; public class MyFrame { public MyFrame() { initComponents(); } private void initComponents() { JWindow w = new JWindow(); w.setSize(300,200); w.setLocationRelativeTo(null); ImageIcon ic=new ImageIcon("C:\\Users\\DEEP\\Desktop\\UI Animation Third\\about.jpg"); JLabel image=new JLabel(resize(ic, 300,200)); JProgressBar pb=new JProgressBar(); pb.setForeground(new Color(51, 153, 51)); w.add(image); w.add(BorderLayout.SOUTH,pb); w.setVisible(true); for(int i=0;i<=100;i++) { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } pb.setValue(i); } if(pb.getValue()==100) { w.dispose(); } } public ImageIcon resize(ImageIcon im,int w,int h) { BufferedImage bi=new BufferedImage(w, h, BufferedImage.TRANSLUCENT); Graphics2D gd=(Graphics2D)bi.createGraphics(); gd.addRenderingHints(new RenderingHints(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY)); gd.drawImage(im.getImage(),0,0,w,h,null); gd.dispose(); return new ImageIcon(bi); } public static void main(String h[]) { new MyFrame(); } }
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment