File: TextDialog.java

package info (click to toggle)
moodle 1.4.4.dfsg.1-3sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 57,876 kB
  • ctags: 29,496
  • sloc: php: 271,617; sql: 5,084; xml: 702; perl: 638; sh: 403; java: 283; makefile: 42; pascal: 21
file content (68 lines) | stat: -rw-r--r-- 1,554 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.awt.*;
import java.awt.event.*;

public class TextDialog
extends Dialog
implements ActionListener
{
 public TextDialog(Frame owner, String title, String textAreaText, String buttonText, boolean modal, int sizeX, int sizeY)
 {
  super(owner, title, modal);
  setBackground(Color.lightGray);
  setLocation(getToolkit().getScreenSize().width - sizeY, 0);
  
  //Layout setzen und Komponenten hinzufgen
  GridBagLayout gbl = new GridBagLayout();
  GridBagConstraints gbc;
  setLayout(gbl);
  
  //TextArea hinzufgen
  TextArea text = new TextArea(textAreaText, 1, 1, TextArea.SCROLLBARS_VERTICAL_ONLY);
  gbc = MainFrameGui.makegbc(0, 0, 1, 1);
  gbc.weightx = 100;
  gbc.weighty = 100;
  gbc.fill = GridBagConstraints.BOTH;
  gbl.setConstraints(text, gbc);
  add(text);
  
  //Button
  Button button = new Button(buttonText);
  gbc = MainFrameGui.makegbc(0, 1, 1, 1);
  gbc.fill = GridBagConstraints.NONE;
  gbc.anchor = GridBagConstraints.SOUTH;
  gbl.setConstraints(button, gbc);
  button.addActionListener(this);
  add(button);

  pack();
  setSize(sizeX, sizeY);
 }
 
 public void actionPerformed(ActionEvent event)
 {
  int i = getSize().height;
  int j = i / 20;
  int oldWidth = getSize().width;
  int oldHeight = getSize().height;
  
  System.out.println(i + " - " + j);
  
  while(i > -1)
  {
   //System.out.println(i);
   setSize(getSize().width, i);
   try
   {
    Thread.sleep(5);
   }
   catch (InterruptedException e)
   {
    //nix
   }
   i = i - j;
  }
  setVisible(false);
  setSize(oldWidth, oldHeight);
  dispose();
 }
}