Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. private JPanel contentPane;
  2.  
  3.  
  4.  
  5. public static void main(String[] args) {
  6. EventQueue.invokeLater(new Runnable() {
  7.  
  8. @Override
  9. public void run() {
  10. try {
  11. Aluno7_Ruben frame = new Aluno7_Ruben();
  12. frame.setVisible(true);
  13. } catch (Exception e) {
  14. e.printStackTrace();
  15. }
  16. }
  17. });
  18. }
  19.  
  20. /**
  21. * Create the frame.
  22. */
  23. public Aluno7_Ruben() {
  24. setIconImage(Toolkit.getDefaultToolkit().getImage("C:\Users\Jou00E3o Gil\workspace\sala de aula\pic\icon\Science-Classroom-icon.png"));
  25.  
  26.  
  27. setTitle("PC7-Ruben Gato");
  28. setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  29. setBounds(100, 100, 450, 300);
  30. contentPane = new JPanel();
  31. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  32. setContentPane(contentPane);
  33. contentPane.setLayout(null);
  34.  
  35. JLabel lblNewLabel = new JLabel("Detalhes/Notas:");
  36. lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 17));
  37. lblNewLabel.setBounds(10, 106, 194, 23);
  38. contentPane.add(lblNewLabel);
  39.  
  40. JLabel lblNewLabel_1 = new JLabel("Localizau00E7u00E3o da avaria:");
  41. lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 17));
  42. lblNewLabel_1.setBounds(10, 11, 169, 20);
  43. contentPane.add(lblNewLabel_1);
  44.  
  45.  
  46. JCheckBox Teclado = new JCheckBox ("Teclado");
  47. Teclado.addActionListener(new ActionListener() {
  48. public void actionPerformed(ActionEvent e) {
  49. PrintWriter writer;
  50. try {
  51. String texto1="O teclado esta danificado";
  52. writer = new PrintWriter("C:\Users\João Gil\workspace\sala de aula\pic\notas.txt");
  53. writer.println(texto1 );
  54.  
  55. writer.close();
  56. } catch (FileNotFoundException e1) {
  57. // TODO Auto-generated catch block
  58. e1.printStackTrace();
  59.  
  60. }
  61.  
  62. }
  63. });
  64. Teclado.setToolTipText("Selecionar caso esteja danificado");
  65. Teclado.setBounds(6, 54, 94, 23);
  66. contentPane.add(Teclado);
  67.  
  68. JCheckBox Rato = new JCheckBox ("Rato");
  69. Rato.setToolTipText("Selecionar caso esteja danificado");
  70. Rato.setBounds(98, 54, 81, 23);
  71. contentPane.add(Rato);
  72.  
  73. JCheckBox Monitor = new JCheckBox ("Monitor");
  74. Monitor.setToolTipText("Selecionar caso esteja danificado");
  75. Monitor.setBounds(190, 54, 96, 23);
  76. contentPane.add(Monitor);
  77.  
  78. JCheckBox Torre = new JCheckBox ("Torre");
  79. Torre.setToolTipText("Selecionar caso esteja danificado");
  80. Torre.setBounds(288, 54, 109, 23);
  81. contentPane.add(Torre);
  82.  
  83. JButton Adicionar_notas = new JButton("Escrever novas notas");
  84. Adicionar_notas.addActionListener(new ActionListener() {
  85.  
  86.  
  87. public void actionPerformed(java.awt.event.ActionEvent evt) {
  88.  
  89. FAZJA(evt);
  90. }
  91.  
  92. });
  93.  
  94.  
  95. Adicionar_notas.setBounds(137, 224, 159, 23);
  96. contentPane.add(Adicionar_notas);
  97.  
  98. File file = new File("C:\Users\João Gil\workspace\sala de aula\pic\notas.txt");
  99. FileInputStream fis = null;
  100. String texto = "";
  101.  
  102. try {
  103. fis = new FileInputStream(file);
  104. int content;
  105. while ((content = fis.read()) != -1) {
  106. texto += (char) content;
  107. }
  108. } catch (IOException e) {
  109. e.printStackTrace();
  110. } finally {
  111. try {
  112. if (fis != null) {
  113. fis.close();
  114. }
  115. } catch (IOException ex) {
  116. ex.printStackTrace();
  117. }
  118. }
  119. JTextArea textArea1 = new JTextArea(texto);
  120.  
  121. textArea1.setEditable(false);
  122. textArea1.setWrapStyleWord(true);
  123. textArea1.setBounds(10, 128, 414, 85);
  124. contentPane.add(textArea1);
  125.  
  126.  
  127. }
  128.  
  129. protected void FAZJA(ActionEvent evt) {
  130. this.dispose();
  131. new Gravação_Dados().setVisible(true);
  132.  
  133.  
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement