rb.addActionListener(new ActionEvent(ae) {
public void actionPerformed(ActionEvent ae) {
nowCall(ae);
}
});
Run Code Online (Sandbox Code Playgroud)
其他方式
Thread th=new Thread(Runnable r) {
public void run() {
// do something
}
};
// notice the ending of above 2 snippets
Run Code Online (Sandbox Code Playgroud)
看到这两个,我真的很困惑.似乎没有确切的模式来声明一个匿名的内部类.
请解释匿名内部类的语法.
我最近在研究课程时遇到过这些术语.我知道他们是data types
...... ?
他们真的吗?
你能解释一下这些术语到底意味着什么吗?我还没有找到documentation
.
码
import javax.swing.*;
import java.awt.*;
class tester {
public static void main(String args[]) {
JFrame fr = new JFrame();
JPanel p = new JPanel();
p.setBackground(Color.RED);
p.paintImmediately(20,20,500,500);
fr.add(p);
fr.setVisible(true);
fr.setSize(2000,2000);
}
}
Run Code Online (Sandbox Code Playgroud)
我得到一个完全是红色的面板.为什么我不接线?我怎么才能得到它?
我想对齐search bar
页面的最右侧.为此,我写了以下内容:
<form method="get" action="#">
<input type="search" name="q" style="text-align:right" />
</form>
Run Code Online (Sandbox Code Playgroud)
但它没有对齐右侧的搜索栏.这是为什么 ?
在下面的脚本中我检查了该class_exists
函数。这个函数的范围是什么?false
当我测试此类时,它会返回此脚本。
<?php
namespace my;
class Tester {
public function check() {
$classname = 'Tester';
if(class_exists($classname)) {
echo "class exists ! <br />";
} else {
echo "class doesn't exist ! <br />";
}
}
}
$obj = new Tester();
$obj->check();
Run Code Online (Sandbox Code Playgroud)
输出:类不存在
对于Graphics
类的方法:fillOval,做什么x
和y
表示什么?文件说:
x - the x coordinate of the upper left corner of the oval to be filled.
y - the y coordinate of the upper left corner of the oval to be filled.
Run Code Online (Sandbox Code Playgroud)
我不明白.这是什么意思 ?
我创建了一个包含一个属性的表,并在其中tt
插入了一个值.
CREATE TABLE tt(tm TIME);
INSERT INTO tt VALUES(2342342);
Run Code Online (Sandbox Code Playgroud)
执行select
命令时,显示的结果如下:
234:23:42
Run Code Online (Sandbox Code Playgroud)
这几点意味着什么?
unlike SwingUtilities.invokeAndWait(), the event thread is permitted to call SwingUtilities.invokeLater()
.我无法理解这一点.
请帮帮我.
#include<stdio.h>
void main() {
int s[4][2]={
{1,2},
{3,4},
{5,6},
{7,8}
};
int (*p)[2]; // what does this statement mean? (A)
int i,j,*pint;
for(i=0;i<=3;i++) {
p=&s[i];
pint=(int*)p; // what does this statement mean? (B)
printf("\n");
for(j=0;j<=1;j++) {
printf("%d",*(pint+j));
}
}
Run Code Online (Sandbox Code Playgroud)
我无法理解陈述'A'和'B'.如何做和做了什么?请非常清楚地解释一下.
如何instance variables
从匿名类的方法中访问?
class Tester extends JFrame {
private JButton button;
private JLabel label;
//..some more
public Tester() {
function(); // CALL FUNCTION
}
public void function() {
Runnable r = new Runnable() {
@Override
public void run() {
// How do I access button and label from here ?
}
};
new Thread(r).start();
}
}
Run Code Online (Sandbox Code Playgroud)