例如,我有一个这样的表:
componentMoved
还有另一张表:
import java.awt.Color;
import static java.awt.Color.BLACK;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import javax.swing.JPanel;
public class JFrameTest extends JFrame {
public JFrameTest() {
setSize(500, 500);
setTitle("Hello :D");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setResizable(false);
JPanel pane = new JPanel() {
@Override
public boolean isOpaque() {
return false;
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g.create();
g2d.setColor(Color.RED);
g2d.fillOval(195, 195, 10, 10);
g2d.dispose();
}
};
setGlassPane(pane);
pane.setVisible(true);
setVisible(true);
}
public static class JPanelTest extends JPanel {
public JPanelTest() {
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.ipadx = 100;
gbc.ipady = 0;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.insets = new Insets(200, 200, 0, 0);
gbc.weightx = 1.0;
gbc.weighty = 1.0;
setBackground(BLACK);
setOpaque(true);
JButton btn = new JButton("Hello");
btn.addComponentListener(new ComponentAdapter() {
@Override
public void componentMoved(ComponentEvent e) {
System.out.println(btn.getLocation());
}
});
add(btn, gbc);
}
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
JFrameTest T = new JFrameTest();
JPanelTest Jp1 = new JPanelTest();
T.add(Jp1);
}
});
}
}
然后我想要一个第三个表格,其中“Score”colunm将通过乘以另外两个表中人物的得分来制作,所以它最终会像这样:
ID | Name | Score
1 | Rob | 9
2 | Anderson | 10
3 | Lina | 6
我怎么能这样做?
答案 0 :(得分:0)
请在下面的第三个表格中填写:
insert into third_table values(SELECT tb1.ID, tb2.Name, (tb1.Score * tb2.Score) as Score FROM tb1, tb2 WHERE tb1.ID = tb2.ID)