Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. jPanel1 = new javax.swing.JPanel(){
  2. @Override
  3. public void paintComponent(Graphics g)
  4. {
  5. g.drawImage(src, 0, 0, null);
  6. }
  7. };
  8.  
  9. // Code of sub-components and layout - not shown here
  10.  
  11. add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 400, 300));
  12.  
  13.  
  14. //Aaand Image:
  15. try {
  16. src = ImageIO.read(new File("splash.png"));
  17. } catch (IOException ex) {
  18. Logger.getLogger(Boot.class.getName()).log(Level.SEVERE, null, ex);
  19. }
  20.  
  21. /////////////////////////////////FULL CODE://////
  22.  
  23. package taban;
  24.  
  25. import java.awt.Frame;
  26. import java.awt.Graphics;
  27. import java.awt.Image;
  28. import java.awt.Toolkit;
  29. import javax.swing.ImageIcon;
  30.  
  31. /**
  32. *
  33. * @author erkanmdr
  34. */
  35. public class Boot extends java.awt.Frame {
  36.  
  37. Image src;
  38.  
  39. /**
  40. * Creates new form Boot
  41. */
  42. public Boot() {
  43. src = Toolkit.getDefaultToolkit().createImage("/home/erkanmdr/splash.png");
  44.  
  45. initComponents();
  46. }
  47.  
  48. /**
  49. * This method is called from within the constructor to initialize the form.
  50. * WARNING: Do NOT modify this code. The content of this method is always
  51. * regenerated by the Form Editor.
  52. */
  53. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  54. private void initComponents() {
  55.  
  56. jPanel1 = new javax.swing.JPanel(){
  57. @Override
  58. public void paintComponent(Graphics g)
  59. {
  60. g.drawImage(src, 0, 0, null);
  61. }
  62. };
  63.  
  64. setUndecorated(true);
  65. setPreferredSize(new java.awt.Dimension(400, 300));
  66. setResizable(false);
  67. setSize(new java.awt.Dimension(400, 300));
  68. addWindowListener(new java.awt.event.WindowAdapter() {
  69. public void windowClosing(java.awt.event.WindowEvent evt) {
  70. exitForm(evt);
  71. }
  72. });
  73. setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
  74. add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 400, 300));
  75.  
  76. pack();
  77. setLocationRelativeTo(null);
  78. }// </editor-fold>
  79.  
  80. /**
  81. * Exit the Application
  82. */
  83. private void exitForm(java.awt.event.WindowEvent evt) {
  84. System.exit(0);
  85. }
  86.  
  87. /**
  88. * @param args the command line arguments
  89. */
  90. public static void main(String args[]) {
  91. java.awt.EventQueue.invokeLater(new Runnable() {
  92. public void run() {
  93. Frame f = new Boot();
  94.  
  95. f.setVisible(true);
  96.  
  97. // this.add(kanvas);
  98. }
  99. });
  100. }
  101.  
  102.  
  103. // Variables declaration - do not modify
  104. private javax.swing.JPanel jPanel1;
  105. // End of variables declaration
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement