Guest User

Untitled

a guest
May 22nd, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. import javax.swing.JFrame;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. import javax.swing.*;
  5. import javax.swing.JOptionPane;
  6. import java.util.Scanner;
  7.  
  8. public class dialog extends JFrame
  9. {
  10.  
  11. private Dimension screenSize;
  12. private int width;
  13. private int height;
  14. final Font font = new Font("Helvetica", 22, 22);
  15. private Image dbImage = null;
  16. private Graphics dbgx;
  17. private Graphics2D dbg;
  18. private JLabel label1;
  19. private JPanel main = new JPanel();
  20. private String text;
  21.  
  22. public dialog(String title, String input)
  23. {
  24. text = input;
  25. JFrame frame = frame(title);
  26. frame.setVisible(true);
  27. frame.repaint();
  28.  
  29.  
  30. }
  31. public void showString(String title, String output){
  32. System.out.println(output);
  33. }
  34. public String returnABCD (String title, String output){
  35. System.out.println(output);
  36. Scanner scan = new Scanner(System.in);
  37. return scan.nextLine();
  38. }
  39. public String returnString (String title, String output){
  40. System.out.println(output);
  41. Scanner scan = new Scanner(System.in);
  42. return scan.nextLine();
  43. }
  44.  
  45. public void paint(Graphics g) {
  46. if (dbImage == null) {
  47. dbImage = createImage(width, height);
  48. dbgx = dbImage.getGraphics();
  49. dbg = (Graphics2D) dbgx;
  50. dbg.setFont(font);
  51. dbg.setColor(Color.BLACK);
  52. dbg.drawString("text why wont this work this is getting really annoying", 20, 10);
  53. g.drawImage(dbImage, 0, 0, null);
  54. }
  55.  
  56. g.drawImage(dbImage, 0, 0, null);
  57. }
  58. public void update(Graphics g) {
  59. paint(g);
  60. }
  61.  
  62.  
  63.  
  64. public JFrame frame(String title)
  65. {
  66. screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  67. width = (int)screenSize.getWidth();
  68. height = (int)screenSize.getHeight();
  69. width = (int) (.375 * width);
  70. height = (int) (.375 * height);
  71. JFrame diaframe = new JFrame(title);
  72. diaframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  73. pack();
  74. diaframe.setSize(new Dimension(width,height));
  75. diaframe.setUndecorated(true);
  76. diaframe.getRootPane().setBorder(BorderFactory.createMatteBorder(4, 4, 4, 4, Color.BLACK));
  77. diaframe.setLocation( 20, 20);
  78. //diaframe.setVisible(true);
  79. return diaframe;
  80. }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment