Advertisement
Lauda

Untitled

Dec 15th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.24 KB | None | 0 0
  1. public class AboutDialog extends JDialog implements ActionListener {
  2.    
  3.     public AboutDialog(Frame parent, String title, boolean modal) {
  4.         super(parent, title, modal);
  5.         setSize(500, 400);
  6.         setLocationRelativeTo(parent);
  7.         setLayout(new BorderLayout());
  8.        
  9.         JPanel panBot = new JPanel(new FlowLayout(FlowLayout.RIGHT));
  10.         JButton btnOk = new JButton("OK");
  11.         btnOk.addActionListener(this);
  12.         getRootPane().setDefaultButton(btnOk);
  13.         panBot.setBackground(Color.WHITE);
  14.         panBot.add(btnOk);
  15.         add(panBot, BorderLayout.SOUTH);
  16.        
  17.          JPanel panTop = new JPanel();
  18.          panTop.setPreferredSize(new Dimension(100,30));
  19.          panTop.setBackground(Color.WHITE);
  20.          panTop.add(new JLabel(Config.getTitle() + " - O Autoru"));
  21.          add(panTop,BorderLayout.NORTH);
  22.          
  23.          JPanel panLeft=new JPanel(new BorderLayout());
  24.          panLeft.setPreferredSize(new Dimension(180,200));
  25.          ImagePanel imgAutor = new ImagePanel(new ImageIcon("img/autor2.jpg").getImage());
  26.          panLeft.add(imgAutor);
  27.          add(panLeft,BorderLayout.WEST);
  28.      
  29.          JPanel panCenter = new JPanel(new BorderLayout());
  30.          JSeparator sep = new JSeparator();
  31.          sep.setOrientation(SwingConstants.VERTICAL);
  32.          panCenter.setPreferredSize(new Dimension(10,400));
  33.          panCenter.add(sep);
  34.          add(panCenter,BorderLayout.CENTER);
  35.          
  36.          Dimension lblDimension = new Dimension(200,20);
  37.          
  38.          Box boxRight = new Box(BoxLayout.Y_AXIS);
  39.          boxRight.setPreferredSize(new Dimension(300,400));
  40.          
  41.          JPanel panDetails1 = new JPanel();
  42.         // panDetails1.add(Box.createGlue());
  43.         // panDetails1.add(boxRight.createVerticalStrut(100));
  44.          JLabel lblImePrz = new JLabel();
  45.          lblImePrz.setPreferredSize(lblDimension);
  46.          lblImePrz.setText("Ime i Prezime: Goran Todorovic");
  47.          panDetails1.add(lblImePrz);
  48.          
  49.          JLabel lblBrInd = new JLabel();
  50.          lblBrInd.setPreferredSize(lblDimension);
  51.          lblBrInd.setText("Broj Indeksa: RA 170/2011");
  52.          panDetails1.add(lblBrInd);
  53.          
  54.          JLabel lblEmail = new JLabel();
  55.          lblEmail.setPreferredSize(lblDimension);
  56.          lblEmail.setText("E-mail: <[email protected]>");
  57.          panDetails1.add(lblEmail);
  58.          
  59.          JLabel lblHobi = new JLabel();
  60.          lblHobi.setPreferredSize(lblDimension);
  61.          lblHobi.setText("Hobi: Sakupljanje salveta.");
  62.          panDetails1.add(lblHobi);
  63.          
  64.          JSeparator sep1 = new JSeparator();
  65.          sep1.setOrientation(SwingConstants.HORIZONTAL);
  66.          sep1.setPreferredSize(new Dimension(300,5));
  67.          panDetails1.add(sep1);
  68.          
  69.          JLabel lblVerzija = new JLabel();
  70.          lblVerzija.setPreferredSize(new Dimension(280, 20));
  71.          lblVerzija.setText("Copyright \u00a9 2013 Goran Todorovic :: verzija: 0.1b");
  72.          panDetails1.add(lblVerzija);
  73.          
  74.          boxRight.add(panDetails1);
  75.          add(boxRight, BorderLayout.EAST);
  76.        
  77.     }
  78.  
  79.     public void actionPerformed(ActionEvent e) {
  80.         if (e.getActionCommand().equals("OK"))
  81.             setVisible(false);
  82.     }
  83. }
  84.  
  85. @SuppressWarnings("serial")
  86. class ImagePanel extends JPanel {
  87.  
  88.       private Image img;
  89.  
  90.       public ImagePanel(String img) {
  91.         this(new ImageIcon(img).getImage());
  92.       }
  93.  
  94.       public ImagePanel(Image img) {
  95.         this.img = img;
  96.       }
  97.  
  98.       public void paintComponent(Graphics g) {
  99.         g.drawImage(img, (int)(this.getSize().getWidth()-img.getWidth(null))/2,
  100.                          (int)(this.getSize().getHeight()-img.getHeight(null))/2, null);
  101.       }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement