小编use*_*955的帖子

Maven 2-无法计算构建计划

我在笔记本电脑上设置了Maven 2.我仍在使用Maven 2的原因是Maven,不知何故,因为我公司的代理而无法工作.

工作环境:Eclipse Helio Service Release 2 Maven 2.2.1 Windows 7

错误消息:

Errors occurred during the build.
Errors running builder 'Maven Project Builder' on project 'StrutsExample'.
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies …
Run Code Online (Sandbox Code Playgroud)

java eclipse maven-2 maven

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

在JScrollPane中获取JPanel

我有一个JScrollPane,我在JScrollPane中放了一个JPanel.JPanel拥有可变数量的JLabel.

这是我如何"新"它:

JPanel dataPanel  = new JPanel();
//then do a for loop to put a few JLabels in dataPanel
JScrollPane scrollPane = new JScrollPane(dataPanel);
Run Code Online (Sandbox Code Playgroud)

我想知道如何在另一堂课中获得这些JLabel?我尝试了以下代码,但无法使用ClassCastException.在那个类中,我成功获得了JScrollPane,我将使用scrollPane来表示它.

//I only put a panel in the JScrollPane, so I used 0 in the getComponent() method
JPanel panel = scrollPane.getComponent(0);
for(int i = 0; i < panel.getComponentCount(); i++){
    JLabel label = (JLabel)panel.getComponent(i);
}
Run Code Online (Sandbox Code Playgroud)

事实上,在声明中:

JPanel panel = scrollPane.getComponent(0);
Run Code Online (Sandbox Code Playgroud)

抛出ClassCastException.

java.lang.ClassCastException: javax.swing.JViewport cannot be cast to javax.swing.JPanel
Run Code Online (Sandbox Code Playgroud)

赞赏求助:)

java swing jpanel jscrollpane jviewport

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

为什么自顶向下归并排序中数组访问是 6NlogN?

我不太明白为什么要通过自上而下的归并排序对长度为 N 的数组进行排序,它只需要 6NlogN 次数组访问。(每级需要6N,高度是lgN,所以总共是6NlgN)

每次合并最多使用 6N 次数组访问(2N 次用于复制,2N 次用于移回,最多 2N 次用于比较)

它不是将 N 个元素复制到辅助数组中,然后将其复制回原始数组(即 2N)吗?2N“后退”是从哪里来的?

这个问题实际上来自算法合并排序中的Progosition G。我想是为了这个。

就是书上的代码如下:

public static void merge(Comparable[] a, int lo, int mid, int hi) 
{  // Merge a[lo..mid] with a[mid+1..hi].
   int i = lo, j = mid+1;
   for (int k = lo; k <= hi; k++)  // Copy a[lo..hi] to aux[lo..hi].
      aux[k] = a[k];
   for (int k = lo; k <= hi; k++)  // Merge back to a[lo..hi].
      if      (i > mid)              a[k] = …
Run Code Online (Sandbox Code Playgroud)

arrays algorithm merge mergesort array-merge

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

prototype [name]和prototype.name有什么区别?

我正在阅读Javascript这本书的好部分并且有一个例子

Function.prototype.method = function(name, func){
    this.prototype[name] = func;
    // this.prototype.name = func;
    return this;
};

Number.method("integer", function(){
    return Math[this<0 ? "ceiling" : "floor"](this);
});

document.writeln((10/3).integer());
Run Code Online (Sandbox Code Playgroud)

我以为this.prototype [name] = func; 和this.prototype.name = func; 是相同的,但似乎他们不是.

当我在Chrome中运行注释掉的语句时,显示错误

"未捕获的TypeError:undefined不是函数"

那声明怎么了?是不是将func分配给了名字?

谢谢

javascript

-1
推荐指数
1
解决办法
49
查看次数