내 메인 클래스가 파일에서 구성을로드 한 다음 프레임을 표시합니다. 나는 이클립스와 같은 진행 막대가있는 스플래시 화면을 만들어서 파일이로드되는 동안 진행이 증가하고 파일이로드 된 후에 스플래시가 사라지도록하려고한다. 그러면 내 메인 프레임이로드됩니다.Eclipse와 같은 진행 표시 줄로 스플래시 화면 만들기
MainClass 코드 :
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:/META-INF/spring/applicationContext.xml");
// splash with progress load till this file is loaded
UserDao userDao = context.getBean(UserDao.class);
isRegistered = userDao.isRegistered();
System.out.println("registered: " + isRegistered);
if (isRegistered) {
// progress finish and hide splash
log.debug("user is registered"); // show frame1
} else {
// progress finish and hide splash
log.debug("user is not registered"); // show frame2
}
}
나는 그래서를 수행하는 방법을 알려 주시기 바랍니다, 스윙과 많은 경험을 필요가 없습니다. 그것은 멈추지 않고 영원히 카운트를 계속 카운터가 지정된 수에 도달 할 때
그것이 (300)에서 중지해야합니다
UPDATE : 나는 다음과 같은 예를 발견,하지만 약간의 문제가 타이머 및 스플래시 화면 숨기기.
파일을로드하는 동안 카운터를 바인딩하려는 경우 파일이로드 될 때까지 진행률이로드되고 진행률이 완료되고 스플래시 화면이 사라집니다.
@SuppressWarnings("serial") @Component public class SplashScreen extends JWindow { static boolean isRegistered; static Log log = LogFactory.getLog(SplashScreen.class); private static JProgressBar progressBar = new JProgressBar(); private static SplashScreen execute; private static int count; private static Timer timer1; public SplashScreen() { Container container = getContentPane(); container.setLayout(null); JPanel panel = new JPanel(); panel.setBorder(new javax.swing.border.EtchedBorder()); panel.setBackground(new Color(255, 255, 255)); panel.setBounds(10, 10, 348, 150); panel.setLayout(null); container.add(panel); JLabel label = new JLabel("Hello World!"); label.setFont(new Font("Verdana", Font.BOLD, 14)); label.setBounds(85, 25, 280, 30); panel.add(label); progressBar.setMaximum(50); progressBar.setBounds(55, 180, 250, 15); container.add(progressBar); loadProgressBar(); setSize(370, 215); setLocationRelativeTo(null); setVisible(true); } public void loadProgressBar() { ActionListener al = new ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { count++; progressBar.setValue(count); if (count == 300) { timer1.stop(); execute.setVisible(false); return; } } }; timer1 = new Timer(50, al); timer1.start(); } public static void main(String[] args) { execute = new SplashScreen(); ApplicationContext context = new ClassPathXmlApplicationContext( "classpath:/META-INF/spring/applicationContext.xml"); UserDao userDao = context.getBean(UserDao.class); isRegistered = userDao.isRegistered(); if (isRegistered) { // show frame 1 } else { // show frame 2 } } }
[이 질문에 답변을 남겼습니까? (http://stackoverflow.com/questions/2089359/java-6-splash-screen?rq=1)? 그것은 좋은 링크가 있습니다. –