Advertisement
Guest User

Untitled

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