Cannot reduce the visibility of the inherited method from 编译错误
来源:互联网 发布:linux c书籍 编辑:程序博客网 时间:2024/05/16 13:59
编译如下代码时,
<pre name="code" class="java">JDesktopPane DESKTOP_PANE = new JDesktopPane() {protected void paintComponent(Graphics g) {g.drawImage(image, 0, 0, getWidth(), getHeight(), null);//g.drawImage(image, 0, 0, 500, 400, null);}};
一切正常。编译如下代码时,
JDesktopPane DESKTOP_PANE = new JDesktopPane() {//protected void paintComponent(Graphics g) {<pre name="code" class="java"> protected void paint(Graphics g) {g.drawImage(image, 0, 0, getWidth(), getHeight(), null);//g.drawImage(image, 0, 0, 500, 400, null);}};发生错误,提示如下信息:
Multiple markers at this line
- overrides javax.swing.JLayeredPane.paint
- Cannot reduce the visibility of the inherited method from
经查 JDesktopPane有paintComponet 和paint 方法。具体而言:
1. paintComponet继承自javax.swing.JComponent。原型: protected void paintComponent(Graphics g)
2. paint 继承自 javax.swing.JLayeredPane。 原型: public void paint(Graphics g)
发生错误的原因 是复写父类的方法,父类是 public 子类变为了protected,违反了 两同两小一大的 一大原则。故错误。修改为public 正确。
http://stackoverflow.com/questions/9035052/cannot-reduce-visibility-of-method-inherited-method-from-parent
http://stackoverflow.com/questions/6851612/java-access-modifiers-and-overriding-methods
0 0
- Cannot reduce the visibility of the inherited method from 编译错误
- Java编译错误:Cannot reduce the visibility of the inherited method from <class>
- Cannot reduce the visibility of the inherited method from
- Java错误提示------------------Cannot reduce the visibility of the inherited method from MouseListener
- java-Cannot reduce the visibility of the inherited method from 父类
- Cannot reduce the visibility of the inherited method from Interface解决办法
- java-Cannot reduce the visibility of the inherited method from 父类
- java-Cannot reduce the visibility of the inherited method from 父类
- Android问题:DescriptionResourcePathLocationType Cannot reduce the visibility of the inherited meth
- Cannot override the final method from HibernateDaoSupport
- must implement the inherited abstract method 问题解决
- [IOS] 错误:Cannot assign to 'self' outside of a method in the init family
- 子类中初始化错误Cannot assign to ’self’ outside of a method in the init family
- Cannot override the final method from SherlockFragmentActivity问题解决方案
- The method of getChildHtml
- Android studio 报Error:The number of method references in a .dex file cannot exceed 64K错误
- 遇到the static method cannot hide instance method from object可能是因为一下原因。
- Cannot make a static reference to the non-static method setInAnimation(Animation) from the type View
- TS流分析
- mysql---文件构成
- 扩展正则表达式
- VS2010 OPENGL配置以及常出现的问题
- 小米口碑营销的五大秘诀
- Cannot reduce the visibility of the inherited method from 编译错误
- android 图片音乐下载
- iOS/iPhone 程序文件目录结构以及启动流程
- iosk开发结构
- cocos2d-x 源码分析 : Ref (CCObject) 源码分析 cocos2d-x内存管理策略
- 内存抖动
- 安卓文件IO部分,东抄西抄来的
- Ardunio mpu6050 dmp 数据通过串口实现与matlab(mac)实时绘图 学习过程 【2014-9-7】
- 指针的引用——在函数中的巧妙应用