我只是实现了继承JPanel的类,如下所示
public class Orpanel extends JPanel {
....
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D)g;
g2d.setPaint(tpaint);
g2d.fill(rect);
}
....
}
Run Code Online (Sandbox Code Playgroud)
Orpanel正在加载图像并调整它自己的大小.
这是问题.
调用JFrame的setContentpane(Orpanel的实例)使它工作正常但是当我将Orpanel附加到JFrame时调用add()方法而不是setContentpane(我知道setcontentpane并不意味着附加..无论如何),它不起作用.
最后想通了当我使用add()方法时,添加到JFrame的Component不会调用paintComponent()方法.即使我手动调用repaint()方法,仍然不会调用paintComponent()方法.
我错过了什么?任何帮助将不胜感激!
thx提前.Jaeyong shin.
我添加了额外的代码.
public Test(OwPanel op)
{
super();
Dimension monitor = Toolkit.getDefaultToolkit().getScreenSize();
op.setBackground(Color.white);
this.setBackground(Color.white);
this.setBounds(monitor.width / 2 - 200 , monitor.height / 2 - 200, 400, 400);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setTitle("test");
this.setLayout(null);
this.getContentPane().add(op);
//this.setContentPane(op);
this.setVisible(true);
this.validate();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
SwingUtilities.invokeLater(new Runnable() {
@Override
public …Run Code Online (Sandbox Code Playgroud)
我想知道 clang 如何在 Windows 系统上工作。
我按照本网站上的教程并成功构建了二进制文件。
这是我的问题。
当我以调试模式构建项目时,它会生成 .exe、.pdb、.ilk。
调试也可以正常工作,但是当我进入某个函数(例如:std::vector<>::push_back)时,它会在 VisualStudio 上找到矢量源文件。
我认为,它不应该找到源文件,因为 push_back 的实现应该属于 libclang。
为什么会发生这种情况?
测试代码如下
auto answer = [](int n)
{
return 32 + n;
};
constexpr int response = answer(10);
Run Code Online (Sandbox Code Playgroud)
和构建命令是
C:/Program Files/LLVM/bin/clang++.exe' -std=c++2a ./example_1.cpp -o example_1.exe --debug
Run Code Online (Sandbox Code Playgroud)
仅供参考 我的系统有 VisualStudio 2015 和 LLVM 9.0。vs代码配置是
/* c_cpp_properties.json */
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/Program Files/LLVM/include/llvm-c",
"C:/Program Files/LLVM/include/clang-c"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "8.1",
"compilerPath": "\"C:/Program Files/LLVM/bin/clang++.exe\"",
"cStandard": …Run Code Online (Sandbox Code Playgroud)