Java学习者论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

恭喜Java学习者论坛(https://www.javaxxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,购买链接:点击进入购买VIP会员
JAVA高级面试进阶视频教程Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程

Go语言视频零基础入门到精通

Java架构师3期(课件+源码)

Java开发全终端实战租房项目视频教程

SpringBoot2.X入门到高级使用教程

大数据培训第六期全套视频教程

深度学习(CNN RNN GAN)算法原理

Java亿级流量电商系统视频教程

互联网架构师视频教程

年薪50万Spark2.0从入门到精通

年薪50万!人工智能学习路线教程

年薪50万!大数据从入门到精通学习路线年薪50万!机器学习入门到精通视频教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程 MySQL入门到精通教程
查看: 1247|回复: 0

关于java编译出错的问题

  [复制链接]

该用户从未签到

发表于 2016-4-10 12:15:44 | 显示全部楼层 |阅读模式
3Java金币
在eclipse编译,错误提示:Exception in thread "main" java.lang.Error: Unresolved compilation problem:
  1. package demo;

  2. import java.text.Format;
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.Collection;
  6. import java.util.Date;
  7. import java.util.HashMap;
  8. import java.util.Iterator;
  9. import java.util.List;
  10. import java.util.Map;
  11. import java.util.Set;
  12. import java.util.TreeSet;

  13. import javax.xml.crypto.Data;

  14. import java.awt.*;
  15. import java.awt.event.*;
  16. import java.io.*;

  17. import javax.swing.*;


  18. public class demo extends JFrame
  19. {
  20.         private JScrollPane scrollPane;
  21.         private JPanel jContenPanel = null;
  22.         private JTextArea jTextArea = null;
  23.         private JPanel controlPanel = null;
  24.         private JButton OpenButton = null;
  25.         private JButton CloseButton = null;
  26.         private Object ;
  27.        
  28.         private JTextArea geTextArea()
  29.         {
  30.                 if(jTextArea == null)
  31.                 {
  32.                         jTextArea = new JTextArea();
  33.                 }
  34.                 return jTextArea;
  35.                
  36.         }
  37.        
  38.         private JPanel getControlPanel()
  39.         {
  40.                 if(controlPanel == null)
  41.                 {
  42.                         FlowLayout flowLayout = new FlowLayout();
  43.                         flowLayout.setVgap(1);
  44.                         controlPanel = new JPanel();
  45.                         controlPanel.setLayout(flowLayout);
  46.                         controlPanel.add(getOpenButton(), null);
  47.                         controlPanel.add(getCloseButton(), null);
  48.                 }
  49.                
  50.                 return controlPanel;
  51.                
  52.         }
  53.        
  54.         private JButton getOpenButton()
  55.         {
  56.                 if(OpenButton == null)
  57.                 {
  58.                         OpenButton = new JButton();
  59.                         OpenButton.setText("写入");
  60.                         OpenButton.addActionListener(new ActionListener()
  61.                         {
  62.                                 public void actionPerformed(ActionEvent e)
  63.                                 {
  64.                                         File file = new File("text.txt");
  65.                                         try
  66.                                         {
  67.                                                 FileWriter out = new FileWriter(file);
  68.                                                 String string = jTextArea.getText();
  69.                                                 out.write(string);
  70.                                                 out.close();
  71.                                         } catch (Exception e2)
  72.                                         {
  73.                                                 // TODO: handle exception
  74.                                                 e2.printStackTrace();
  75.                                         }
  76.                                        
  77.                                 }
  78.                         });
  79.                
  80.         }

  81.                 return OpenButton;
  82.         }
  83.        
  84.         private JButton getCloseButton()
  85.         {
  86.                 if(CloseButton == null)
  87.                 {
  88.                         CloseButton = new JButton();
  89.                         CloseButton.setText("读取");
  90.                         CloseButton.addActionListener(new ActionListener()
  91.                         {
  92.                                 public void actionPerformed(ActionEvent e)
  93.                                 {
  94.                                         File file = new File("text.txt");
  95.                                         try
  96.                                         {
  97.                                                 FileReader in = new FileReader(file);
  98.                                                 char byt[] = new char[1024];
  99.                                                 int len = in.read(byt);
  100.                                                 jTextArea.setText(new String(byt, 0, len));
  101.                                                 in.close();
  102.                                         } catch (Exception e2)
  103.                                         {
  104.                                                 // TODO: handle exception
  105.                                                 e2.printStackTrace();
  106.                                         }
  107.                                        
  108.                                 }
  109.                         });
  110.                 }
  111.                
  112.                 return CloseButton;
  113.         }

  114.         public demo()
  115.         {
  116.                 super();
  117.                 Init();
  118.         }
  119.        
  120.         private void Init()
  121.         {
  122.                 this.setSize(300, 200);
  123.                 this.setContentPane(getJContentPane());
  124.                 this.setTitle("读写文件");
  125.                
  126.         }
  127.        
  128.         private JPanel getJContentPane()
  129.         {
  130.                 if(jContenPanel == null)
  131.                 {
  132.                         jContenPanel = new JPanel();
  133.                         jContenPanel.setLayout(new BorderLayout());
  134.                         jContenPanel.add(getScrollPanel(), BorderLayout.CENTER);
  135.                         jContenPanel.add(controlPanel, BorderLayout.SOUTH);
  136.                 }
  137.                 return jContenPanel;
  138.         }

  139.        
  140.         public static void main(String[] args)
  141.         {
  142.                 demo thisclass = new demo();
  143.                 thisclass.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  144.                 thisclass.setVisible(true);
  145.         }
  146.        
  147.         protected JScrollPane getScrollPanel()
  148.         {
  149.                 if(scrollPane == null)
  150.                 {
  151.                         scrollPane = new JScrollPane();
  152.                         scrollPane.setViewportView(geTextArea());
  153.                 }
  154.                 return scrollPane;
  155.         }

  156. }


复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Java学习者论坛 ( 声明:本站资料整理自互联网,用于Java学习者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

GMT+8, 2024-4-25 01:28 , Processed in 0.408316 second(s), 45 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表