悟
悟峰
Unregistered / Unconfirmed
GUEST, unregistred user!
JCreator編輯,代碼如下:package myprojects.jniframe;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class JNIFrame extends JFrame implements ActionListener {
int hwnd;
String title="testJNI";
JButton jb1,jb2,jb3,jb4;
static
{
System.loadLibrary("Winlib");
}
public static native int getHwnd(String title);
public static native void toFront(int hwnd);
public static native void flash(int hwnd);
public static native void noSizeChange(int hwnd);
public static native void restore(int hwnd);
public JNIFrame() {
JPanel jp=new JPanel();
Container cp=getContentpane();
jb1=new JButton("總在最前");
jb2=new JButton("閃爍標題");
jb3=new JButton("只顯示標題欄");
jb4=new JButton("恢復");
jp.setLayout(new FlowLayout());
jp.add(jb1);
jp.add(jb2);
jp.add(jb3);
jp.add(jb4);
setTitle(title);
setSize(250,100);
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
jb4.addActionListener(this);
this.addWindowListener(new WindowAdapter()
{
public void windowOpened(WindowEvent we)
{
hwnd=getHwnd(title);
System.out.println(hwnd);
}
}
);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
show();
}
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource()==jb1)
toFront(hwnd);
else
if (ae.getSource()==jb2)
flash(hwnd);
else
if (ae.getSource()==jb3)
noSizeChange(hwnd);
else
restore(hwnd);
}
public static void main(String args[]) {
JNIFrame mainFrame = new JNIFrame();
mainFrame.setTitle("JNIFrame");
}
}
出現錯誤提示如下,何故?
C:/Program Files/Xinox Software/JCreator Pro/MyProjects/Helloworld3/variableclass/customer/cathcdemo/labeldemo/labeldemo/uselistenerdemo/hello/sever/JNIFrame/JNIFrame.java:34: cannot resolve symbol
symbol : method getContentpane ()
location: class myprojects.jniframe.JNIFrame
Container cp=getContentpane();
^
1 error
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class JNIFrame extends JFrame implements ActionListener {
int hwnd;
String title="testJNI";
JButton jb1,jb2,jb3,jb4;
static
{
System.loadLibrary("Winlib");
}
public static native int getHwnd(String title);
public static native void toFront(int hwnd);
public static native void flash(int hwnd);
public static native void noSizeChange(int hwnd);
public static native void restore(int hwnd);
public JNIFrame() {
JPanel jp=new JPanel();
Container cp=getContentpane();
jb1=new JButton("總在最前");
jb2=new JButton("閃爍標題");
jb3=new JButton("只顯示標題欄");
jb4=new JButton("恢復");
jp.setLayout(new FlowLayout());
jp.add(jb1);
jp.add(jb2);
jp.add(jb3);
jp.add(jb4);
setTitle(title);
setSize(250,100);
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
jb4.addActionListener(this);
this.addWindowListener(new WindowAdapter()
{
public void windowOpened(WindowEvent we)
{
hwnd=getHwnd(title);
System.out.println(hwnd);
}
}
);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
show();
}
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource()==jb1)
toFront(hwnd);
else
if (ae.getSource()==jb2)
flash(hwnd);
else
if (ae.getSource()==jb3)
noSizeChange(hwnd);
else
restore(hwnd);
}
public static void main(String args[]) {
JNIFrame mainFrame = new JNIFrame();
mainFrame.setTitle("JNIFrame");
}
}
出現錯誤提示如下,何故?
C:/Program Files/Xinox Software/JCreator Pro/MyProjects/Helloworld3/variableclass/customer/cathcdemo/labeldemo/labeldemo/uselistenerdemo/hello/sever/JNIFrame/JNIFrame.java:34: cannot resolve symbol
symbol : method getContentpane ()
location: class myprojects.jniframe.JNIFrame
Container cp=getContentpane();
^
1 error