小编Dan*_*iel的帖子

Makefile - 仅在文件不存在时才创建依赖项

就像标题所说的那样,我想只在某个文件不存在的情况下才会产生依赖关系,而不是每次都更新时.

我有一个根目录(带有makefile的目录),在其中有一个名为"example"的子目录.在我的根目录中有四个.h文件(functions.h,parser.h,node.h和exception.h),如果那些.h文件还不存在,我想复制到"example"子目录在"例子"中.

不幸的是,我不能只是在"示例"中创建标准依赖项来检查头文件,因为每次我将头文件从root复制到"example"时,"example"中的头文件将被视为已更新并将触发该依赖项每次我跑的时候.我希望有一种方法可以让我的makefile将头文件从根目录复制到"example",只要它们在"example"中不存在.

dependencies makefile target file-exists

17
推荐指数
1
解决办法
2万
查看次数

Java - Swing - JTable - 为所选行设置颜色,但不为Cell设置颜色

我试图让我的表在单击一个单元格时选择整行(这可以通过关闭列选择来完成),但是,我不希望您单击的特定单元格周围的额外粗边框突出显示.我希望这很容易,但显然它涉及渲染器所以我做了很多研究,我能得到的最接近的是:

    JTable contactTable = new JTable(tableModel);

    contactTable.setCellSelectionEnabled(true);
    contactTable.setColumnSelectionAllowed(false);
    contactTable.setRowSelectionAllowed(false);
    contactTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // This renderer extends a component. It is used each time a
    // cell must be displayed.
    class MyTableCellRenderer extends JLabel implements TableCellRenderer {
        // This method is called each time a cell in a column
        // using this renderer needs to be rendered.
        public Component getTableCellRendererComponent(JTable table, Object value,
                boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {
            // 'value' is value contained in the cell located at
            // …
Run Code Online (Sandbox Code Playgroud)

java swing jtable colors cell

8
推荐指数
2
解决办法
3万
查看次数

在VBA shell命令中使用AppActivate和Sendkeys

我想在VBA中使用shell命令在应用程序之间来回切换.我正在使用SendKeys来处理进程A中的内容然后转移到进程B,然后进行处理A然后进程B.它适用于第一次迭代.当我使用AppActivate返回进程B时,它实际上确实将焦点切换回进程B.但是,它忽略了来自SendKeys的后续命令.

示例代码:

Sub pastePDF2TXT_v3(pdfName As String, txtName As String)


Dim acrobatID
Dim acrobatInvokeCmd As String
Dim acrobatLocation As String

Dim notepadID

Dim acrobatID2
Dim notepadID2

Debug.Print "here"


acrobatLocation = "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe"

acrobatInvokeCmd = acrobatLocation & " " & pdfName

acrobatID = Shell(acrobatInvokeCmd, 1)
AppActivate acrobatID
SendKeys "^a", True  '^A selects everything already in the pdf file.
SendKeys "^c", True  '^C copies the selection to the clipboard.



notepadID = Shell("NOTEPAD.EXE " & txtName, 1)  ' invoke notepad on the text …
Run Code Online (Sandbox Code Playgroud)

shell vba sendkeys

6
推荐指数
1
解决办法
9万
查看次数

Java Swing - 使用Line Border在TextArea上设置边距

正如标题所说,我只是试图在TextArea上设置一个LineBorder设置的边距(提供一些填充).没有设置边框,.setMargins工作正常.这是特定的代码块.

aboutArea = new JTextArea("program info etc.....");

Border border = BorderFactory.createLineBorder(Color.BLACK);

aboutArea.setSize(400, 200);
aboutArea.setBorder(border);
aboutArea.setEditable(false);
aboutArea.setFont(new Font("Verdana", Font.BOLD, 12));

add(aboutArea);
Run Code Online (Sandbox Code Playgroud)

我尝试过以下各项:

aboutArea.setMargins(10,10,10,10);
.getBorders(aboutArea).set(10,10,10,10);
UIManager.put("aboutArea.margin", new Insets(10, 10, 10, 10));
Run Code Online (Sandbox Code Playgroud)

但是在应用边框后没有任何影响边距,填充总是为0.任何想法如何在带有边框的textArea上设置填充?

java swing textarea margins insets

6
推荐指数
1
解决办法
4万
查看次数

如何从javascript中调用applet中声明的方法

我正在尝试创建一个基本的Java Applet,以便在客户端的计算机上为它们打开文件.我想通过javascript在下面的java applet中调用openFile函数.

import java.awt.Desktop;
import java.io.File;
import java.io.IOException;

import javax.swing.JApplet;

public class Test extends JApplet {
    public void openFile(String filePath) {
        File f = new File(filePath);

        try {
            Desktop.getDesktop().open(f);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的网页的身体标签之间我有以下内容:

<applet code="Test.class" height="0" width="0"></applet>

<script type="text/javascript">
    document.applets[0].openFile("C:\\test.log");
</script>
Run Code Online (Sandbox Code Playgroud)

当我加载页面时,我收到错误:

TypeError:Object#没有方法'openFile'

有谁知道我需要做些什么来修复这个错误并使applet工作?

javascript java applet

5
推荐指数
1
解决办法
2万
查看次数

C++受保护的变量不是继承的

我编写了一些代码来计算RSA加密算法.该程序使用类和继承,因为我想为多个用户计算公钥和私钥.有一个父类rsa和子类public_keyprivate_key.

编译下面的代码时,我收到很多错误.所有这些都是关于派生类没有各自构造函数中的可用字段(请参阅代码下面的错误消息).但是,这些变量是使用protected父类中的访问修饰符定义的,因此子类应该可以访问它们.

一方面注意:我key在两个子类中都有这个函数,但我认为最好把它放在父类中一次,这是对的吗?

这是代码:

#include <iostream>
#include <math.h>

using namespace std;

class rsa
{
protected:
    int p, q, d, m, n, f, e, c, end, k;

public:
    rsa() : n(0), e(0), c(0), k(0), end(0), f(0)
    { }

    void set(int , int , int, int);

    int key()
    {
        n = p * q;
        f = (p - 1) * (q - 1);

        for (k; end < 1; k++)
        {
            if ((1 …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance class protected member

0
推荐指数
2
解决办法
1230
查看次数