空的字符串是””,不带空格
outputStream 在打印时,打印的内容后面不要加\n,否则对方接受和判断不正确
G:\PROJECTION\IC2N\1c2njava>javac Jsu.netframe.java
Jsubnetframe.java:22: Jsubnetframe should be declared abstract; it does not defi
ne valueChanged(javax.swing.event.ListSelectionEvent) in Jsubnetframe
public class Jsubnetframe extends JFrame implements ListSelectionListener {
^
Jsubnetframe.java:68: cannot resolve symbol
symbol : class TableModel
location: class Jsubnetframe
TableModel dataModel = new AbstractTableModel() {
^
Jsubnetframe.java:68: cannot resolve symbol
symbol : class AbstractTableModel
location: class Jsubnetframe
TableModel dataModel = new AbstractTableModel() {
^
Jsubnetframe.java:89: addActionListener(java.awt.event.ActionListener) in javax.
swing.AbstractButton cannot be applied to (Jsubnetframe)
cancelb.addActionListener(this);
^
Note: Jsubnetframe.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
4 errors
原因是没有import javax.swing.table.*;
G:\PROJECTION\IC2N\1c2njava>javac Jhpportframe.java
Jhpportframe.java:27: Jhpportframe should be declared abstract; it does not defi
ne mousePressed(java.awt.event.MouseEvent) in Jhpportframe
public class Jhpportframe extends JFrame implements
^
Note: Jhpportframe.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
1 error
Jhpportframe should be declared abstract; it does not defi 原因是因为在这里必须用MouseListener 的相关方法进行覆盖,也就是说必须加入如下的方法:
public void mousePressed(MouseEvent evt) {//if (audio != null) audio.play();}
public void mouseEntered (MouseEvent me) {}
public void mouseExited (MouseEvent me) {}
public void mouseReleased(MouseEvent me) {}
鼠标左键和右件的事件获取:
public void mousePressed(MouseEvent evt) {
Point point1=evt.getPoint();
int x,y;
int onmask = evt.BUTTON1_DOWN_MASK;//左键的ID号
if ((evt.getModifiersEx() & onmask ) == onmask) // 点击左键时
{
}
else //点击右键时
抽象类,不能进行初始化或者生成实例
hpportimg=new Image(getDocumentBase(),”aaa.gif”);
这句话是错的,因为Image()是抽象类,不能进行初始化或者生成实例.,应该用:
hpportimg=getImage(“adf.gif”);
并且应该注意它不能放在构造函数中,而应该放在INIT()等方法中.
文章来源于领测软件测试网 https://www.ltesting.net/