public static void splash() { try { final BufferedImage img = ImageIO.read(Splash.class.getResourceAsStream("/path/to/your/splash/image/splash.png")); JDialog dialog = new JDialog() { @Override public void paint(Graphics g) { g.drawImage(img, 0, 0, null); } }; // use the same size as your image dialog.setPreferredSize(new Dimension(450, 300)); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.setUndecorated(true); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); dialog.repaint(); try { // Now, we are going to init the look and feel: Class uim = Class.forName("javax.swing.UIManager"); uim.getDeclaredMethod("setLookAndFeel", String.class) .invoke( null, (String) uim.getDeclaredMethod("getSystemLookAndFeelClassName").invoke(null)); // And now, we are going to invoke our loader method: Class clazz = Class.forName("yourpackage.YourClass"); dialog.dispose(); // suppose your method is called init and is static clazz.getDeclaredMethod("init").invoke(null); } catch (Exception ex) { ex.printStackTrace(); } dialog.dispose(); } catch (IOException ex) { ex.printStackTrace(); } }
public void repaint() { super.repaint(); }
public Login(JFrame dialogOwner) { login = new JDialog(dialogOwner, "LOGIN", true); login.setSize(290, 150); login.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); login.setLayout(null); login.getContentPane().setBackground(Color.white); lblUeberschrift = new JLabel("Login to BigOne"); lblUeberschrift.setBounds(10, 10, 270, 25); lblName = new JLabel("Username"); lblName.setBounds(10, 40, 100, 25); lblPW = new JLabel("Password"); lblPW.setBounds(10, 70, 100, 25); txtBenutzer = new JTextField(); txtBenutzer.setBounds(120, 40, 120, 25); // txtBenutzer.setText(""); txtPW = new JPasswordField(""); txtPW.setBounds(120, 70, 120, 25); // txtPW.setText(""); btnLogin = new JButton("Login"); btnLogin.setBounds(100, 100, 90, 25); btnLogin.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // zuweisung der Textfeldwerte an die lokalen Varablen strB = txtBenutzer.getText(); strPW = new String(txtPW.getPassword()); try { // Select fitting database driver and connect: Class.forName(strDbDrv); cn = DriverManager.getConnection(strDbUrl + strDatabase, strB, strPW); login.dispose(); } catch (Exception ex) { // ausnahme beschreibung auf der konsole ausgeben txtPW.setText(""); txtPW.requestFocus(); Logincount++; if (Logincount == 3) { JOptionPane.showMessageDialog( null, "maximale Anzahl der Loginversuche überschritten", "Achtung", JOptionPane.INFORMATION_MESSAGE); login.dispose(); } // System.out.println(ex.toString()); } } }); login.add(lblUeberschrift); login.add(lblName); login.add(lblPW); login.add(txtBenutzer); login.add(txtPW); login.add(btnLogin); login.validate(); login.repaint(); login.setVisible(true); txtBenutzer.requestFocus(); }
@SuppressWarnings("unchecked") private void showList() { LinkedList<String> ll = new LinkedList<String>(); LinkedList<String> ll2 = null; inJarTree = false; String s = listHead; if (s.toLowerCase().endsWith("package.json")) { ll2 = buildListFromJSON(s); // fullNodeName = s; // showFileNames(); } else { if (-1 == s.indexOf("!")) { // if fullNodeName is NOT a // file // within a jar file ... if (listHead == null) return; File f = new File(listHead); if (!f.exists() || !f.isDirectory()) return; String[] fl = f.list(); ll2 = new LinkedList<String>(); if (fl == null || fl.length == 0) { ll2.add("(empty folder)"); } else { for (int j = 0; j < fl.length; j++) { String fn = s + File.separator + fl[j]; File fx = new File(fn); if (!fx.exists()) continue; if (fx.isDirectory()) ll.add(fl[j]); // directories go into ll first } for (int j = 0; j < fl.length; j++) { String fn = s + File.separator + fl[j]; File fx = new File(fn); if (!fx.exists()) continue; if (!fx.isDirectory() && (fCParms.filter.accept(fx) || driver.allFiles)) ll2.add(fl[j]); // non-directories go into ll2, // which is // then sorted, and then added // to ll } } } else { inJarTree = true; if (currentNode == null) return; Enumeration<DefaultMutableTreeNode> e = currentNode.children(); ll = new LinkedList<String>(); ll2 = new LinkedList<String>(); while (e.hasMoreElements()) { DefaultMutableTreeNode node = (e.nextElement()); Object obj = node.getUserObject(); ll2.add((String) obj); } } } if (ll2 == null) return; Collections.sort(ll2, comp); for (String li : ll2) { ll.add(li); } if (!inJarTree) { if (listHead.equals(listShowingJarFile)) { s = driver.javaFBPJarFile; // int j = s.lastIndexOf(File.separator); // s = s.substring(j + 1); ll.add(s); } } Object[] oa = ll.toArray(); nodeNames = new String[oa.length]; for (int j = 0; j < oa.length; j++) { nodeNames[j] = (String) oa[j]; } list = new JList<String>(nodeNames); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addKeyListener(this); list.addMouseListener(this); list.addListSelectionListener(this); list.setFocusTraversalKeysEnabled(false); order.remove(3); order.add(3, list); list.setFixedCellHeight(driver.fontg.getSize() + 2); list.setCellRenderer(renderer); list.setEnabled(true); if (!saveAs) list.addAncestorListener(new RequestFocusListener()); if (listView != null) panel.remove(listView); listView = new JScrollPane(list); panel.add(listView, BorderLayout.CENTER); selComp = list; list.setSelectedIndex(0); list.setFocusable(true); list.setVisible(true); // list.requestFocusInWindow(); paintList(); frame.pack(); listView.repaint(); dialog.repaint(); panel.validate(); panel.repaint(); frame.repaint(); }