小编Eri*_*ric的帖子

在项目中包含 JNA 代码 - 编译错误

我正在使用另一篇 StackOverflow 帖子 - Java - 如何快速截取屏幕截图中的示例代码,但我遇到了一些问题。

我从其Github 存储库下载了 JNA 文件,然后将该文件复制到 JAR 文件中,并将其放入我的程序所在的同一文件夹中。但是当我尝试编译我的程序时,它给了我很多错误,如下所示:

C:\Users\windows\Desktop\testPrintScreen>javac JNAScreenShot.java
JNAScreenShot.java:12: error: package com.sun.jna.platform.win32 does not exist
import com.sun.jna.platform.win32.W32API;
                             ^
JNAScreenShot.java:129: error: package com.sun.jna.platform.win32 does not exist
interface GDI32 extends com.sun.jna.platform.win32.GDI32 {

                                              ^
JNAScreenShot.java:58: error: cannot find symbol
bufferedImageFromBitmap(GDI32.HDC        blitDC,
                             ^
symbol:   class HDC
location: interface GDI32
JNAScreenShot.java:59: error: cannot find symbol
                        GDI32.HBITMAP    outputBitmap,
                             ^
symbol:   class HBITMAP
location: interface GDI32
JNAScreenShot.java:60: error: cannot find symbol
                        GDI32.BITMAPINFO bi) {
                             ^
 symbol:   class BITMAPINFO …
Run Code Online (Sandbox Code Playgroud)

java windows jna

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

在javascript中循环一系列图像

我想在 javascript 中循环一系列图像。下面是我到目前为止的代码

<html>
<head>
</head>

<body>
<img src="images/image1.jpg" alt="rotating image" width="600" height="500" id="rotator">

<script type="text/javascript">
(function() {
var rotator = document.getElementById('rotator');  // change to match image ID
//var imageDir = 'images/';                          // change to match images folder
var delayInSeconds = 1;                            // set number of seconds delay
// list image names
var images = ['1.jpg','2.jpg', '3.jpg', '4.jpg'];

// don't change below this line
var num = 0;
var changeImage = function() {
    var len = images.length;
    rotator.src = images[num++]; …
Run Code Online (Sandbox Code Playgroud)

javascript loops

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

计算目录中的图像

我想要计算目录中有多少图像.我有一些来自互联网的代码的副本,可以检测目录中的总文件.

import java.io.*;

public class CountFilesInDirectory {
      public static void main(String[] args) {
            File f = new File("/home/pc3/Documents/ffmpeg_temp/");
            int count = 0;
            for (File file : f.listFiles()) {
                    if (file.isFile()) {
                            count++;
                    }
            }
            System.out.println("Number of files: " + count);
    }
}
Run Code Online (Sandbox Code Playgroud)

我希望计算一个特定的文件类型,如jpg/txt.我该怎么办?

java file count detect

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

找不到符号动作监听器

我正在使用JFileChooser进行浏览文件类.我在编译时遇到问题.它告诉我比找不到符号actionlistener.下面是我的代码:

import java.util.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.text.*;
import javax.swing.filechooser.*;


public class BrowseForFile 
{
private JTextField txtFileName;
private JFrame layout;

public BrowseForFile()
{
    super();
    initialize();
}

    public void initialize() 
    {
        //empty layout
        layout = new JFrame();
        layout.setTitle("Task Synchronization ");
        layout.setBounds(100, 100, 800, 600);
        layout.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        layout.getContentPane().setLayout(null);

        //set the copyright
        JLabel lblNewLabel_5 = new JLabel("(c) 2012 All Rights Reserved");
        lblNewLabel_5.setForeground(Color.GRAY);
        lblNewLabel_5.setFont(new Font("Tahoma", Font.PLAIN, 10));
        lblNewLabel_5.setHorizontalAlignment(SwingConstants.RIGHT);
        lblNewLabel_5.setBounds(527, 548, 255, 14);
        layout.getContentPane().add(lblNewLabel_5);

        //set the label
        JLabel lblSendAFile = new JLabel("Select a …
Run Code Online (Sandbox Code Playgroud)

java import swing jfilechooser actionlistener

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

编译列表时出错

我正在尝试一些代码,但我无法编译它.有什么错误吗?我已附上以下代码.

import java.util.*;
import java.io.*;
import javax.swing.*;
import java.awt.event.*;

public class Node
{
  private int nodeId;
  private List<Connection> outboundConnections = new ArrayList<>();

  public Node(int nodeId)
  {
    this.nodeId = nodeId;
  }

  public void addConnection(Connection connection)
  {
    this.outboundConnections.add(connection);
  }
}
Run Code Online (Sandbox Code Playgroud)

当我编译时,我遇到了这种错误:

Node.java:9: error: cannot find symbol

  private List<Connection> outboundConnections = new ArrayList<>();

               ^
  symbol:   class Connection

  location: class Node

Node.java:16: error: cannot find symbol

  public void addConnection(Connection connection)
                            ^
  symbol:   class Connection

  location: class Node

Node.java:9: error: unexpected type

  private List<Connection> outboundConnections …
Run Code Online (Sandbox Code Playgroud)

java arraylist

0
推荐指数
1
解决办法
72
查看次数

程序停止工作并退出

我正在用c ++读取文件,这是我的代码:

#include <iostream>
#include <fstream>
#include <algorithm>
#include <climits>
using namespace std;

int main()
{
int row=0;
int col=0;
ifstream inputFile;
int arr[16][5];

    inputFile.open("hdtt4req.txt");

if(inputFile.is_open()) {
        inputFile >> arr[row][col];
        for (row = 0; row < 16; row++) {
            for (col = 0; col < 5; col++) {
                cout <<"hi"; //arr[row][col];
                cout << endl;
            }
        }
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是我想要阅读的文件:

1 2 2 1 2 
2 1 1 1 2 
3 1 1 1 6 
4 2 2 3 …
Run Code Online (Sandbox Code Playgroud)

c++ multidimensional-array readfile

0
推荐指数
1
解决办法
92
查看次数