我正在使用Netbeans 7.1.2创建一个应用程序,我正在使用文件选择器,但我不希望文件选择器获取文件,而是我希望它返回它当前所在目录的完整路径.
当用户在此处单击打开时,我希望它返回完整路径而不是文件.我该怎么做呢?
我正在为ipad创建一个应用程序,我正在使用Java.JavaScript的.HTML和休息.我有一个国家列表,我想在应用程序的页面之一的下拉列表中显示我试图使用rest来填充此列表,但是当我运行应用程序时,我在droplist中没有得到任何东西,safari正在给予错误
Assertion failed: (anonymous function) :449
Run Code Online (Sandbox Code Playgroud)
我得到了这个错误8次,最后有不同的数字
这是我正在使用的一些代码
main.html中
<div id="wrapper">
<div id="mainBackground">
<div id="stflogo"><img src="images/logo.png" width="200" height="186" alt="MyLogo logo" /></div>
<div id="formContainer">
<h1>Register Your Card</h1>
<form id="AccountDetailsForm" method="post" data-ajax="false">
<input id="tfscCardNumber" type="hidden" name="tfscCardNumber" class="readonly" minlength="2" maxlength="20" readonly="readonly" disabled="disabled"/>
<p><label id="firstNameLabel" for="firstName" class="displayBlockLabel RequiredField">First Name </label>
<input id="firstName" type="text" name="firstName" class="required" minlength="2" maxlength="20"/></p>
<p><label id="lastNameLabel" for="lastName" class="displayBlockLabel RequiredField"> Last Name </label>
<input id="lastName" type="text" name="lastName" class="required" minlength="2" maxlength="25"/></p>
<p><label id="address1Label" for="address1" class="displayBlockLabel RequiredField">Address 1 </label>
<input id="address1" type="text" name="address1" class="required" …
Run Code Online (Sandbox Code Playgroud) 我目前正在将文件夹从一个地方复制到另一个地方.它工作正常,但它没有复制原始文件夹,所有其他文件和文件夹也在其中.这是我正在使用的代码:
public static void copyFolder(File src, File dest) throws IOException {
if (src.isDirectory()) {
//if directory not exists, create it
if (!dest.exists()) {
dest.mkdir();
}
//list all the directory contents
String files[] = src.list();
for (String file : files) {
//construct the src and dest file structure
File srcFile = new File(src, file);
File destFile = new File(dest+"\\"+src.getName(), file);
//recursive copy
copyFolder(srcFile,destFile);
}
} else {
//if file, then copy it
//Use bytes stream to support all file types
InputStream …
Run Code Online (Sandbox Code Playgroud) 我正在使用OOP创建一个简单的保龄球游戏,我希望每个碗都有一个类,一个由两个碗组成的Frame类,以及一个由十个帧组成的Game类.
目前我有这样的事情
Bowl.java
public class Bowl {
int bowlScore = 0;
public Bowl(int pinsKnocked){
bowlScore = pinsKnocked;
}
}
Run Code Online (Sandbox Code Playgroud)
Frame.java
public class Frame{
int firstScore;
int secondScore;
public Bowl firstBowl;
public Bowl secondBowl;
public Frame (){
firstBowl = new Bowl(0);
secondBowl = new Bowl(0);
}
public Frame (int firstScore, int secondScore){
firstBowl = new Bowl(firstScore);
secondBowl = new Bowl(secondScore);
}
Run Code Online (Sandbox Code Playgroud)
Game.java
public class Game {
int totalScore;
public Frame firstFrame;
public Frame secondFrame;
...
public Frame tenthFrame;
public Game(){
firstFrame …
Run Code Online (Sandbox Code Playgroud) 有没有办法像使用类似的东西一样在 JTree 中获取选定节点的选定路径
String pathForNode = JTree.getLastSelectedPathComponent().getPath().toString();
Run Code Online (Sandbox Code Playgroud) 我试图创建一个使用Spring,Maven和Hibernate访问sql server数据库的应用程序.当我尝试运行应用程序时,我收到以下错误:
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [spring/database/DataSource.xml]: Could not resolve placeholder 'jdbc.driverClassName'
Run Code Online (Sandbox Code Playgroud)
这是我的课程
DataSoucre.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>/properties/database.properties</value>
</property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud)
Hibernate.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- Hibernate session factory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/> …
Run Code Online (Sandbox Code Playgroud) 我正在尝试学习如何使用DAO和BO类,我收到以下错误
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring/database/Hibernate.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'annotatedClasses' of bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Bean property 'annotatedClasses' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Run Code Online (Sandbox Code Playgroud)
Hibernate.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- Hibernate session factory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!--class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">-->
<property name="dataSource">
<ref …
Run Code Online (Sandbox Code Playgroud) 我在网上找到了关于JavaCompiler的代码
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
int result = compiler.run(null, null, null,
"src/org/kodejava/example/tools/Hello.java");
Run Code Online (Sandbox Code Playgroud)
它说的compiler.run(null, null, null
这三个空是默认System.in
,System.out
并System.err
分别.但是这些值实际上做了什么,因为我找不到这些的API?有人可以解释一下吗?
java compiler-construction api compilation java-compiler-api
我正在创建一个应用程序,它从所选目录中获取.java和.class文件的列表,并将它们放在JList中.我正在使用Netbeans 7.1.2.
目前我正在检索文件并将其放入List<File>
.我将列表中的所有文件打印出来但我无法将它们添加到我的表单中的JList.
这是我如何将文件添加到列表中
List<File> filesInDirectory = new ArrayList<>();
public List listFilesForFolder(final File folder) {
for (final File fileEntry : folder.listFiles()) {
if (fileEntry.isDirectory()) {
listFilesForFolder(fileEntry);
} else {
if(fileEntry.toString().toUpperCase().endsWith(".CLASS") || fileEntry.toString().toUpperCase().endsWith(".JAVA")){
filesInDirectory.add(fileEntry);
System.out.println(fileEntry.getName());
}
}
}
return filesInDirectory;
}
Run Code Online (Sandbox Code Playgroud)
有人知道怎么做这个吗?
我创建一个应用程序,从所选目录中获取.java和.class文件的列表,并将它们放在JList中.我正在使用Netbeans 7.1.2.
我有像我想要的那样在JList中显示所有文件,我似乎无法打开jTextArea中打开选定的.java文件.
我需要从JList获取文件以将其传递到JTextArea但它无法正常工作
try
{
FileReader reader= new FileReader( jlist.getSelectedValue() );
BufferedReader br = new BufferedReader( reader);
textarea.read( br );
br.close();
textarea.requestFocus();
}
catch(Exception e2) {}
Run Code Online (Sandbox Code Playgroud)
有人看到我哪里出错吗?
我有一个方法接受a List<>
并将列表中的所有数字加在一起,如果数字= 100则返回
我的问题是我想对许多不同类型的列表使用相同的方法
所以没有这个
public boolean checkPercent(List<BarStaff> associates){..same..}
public boolean checkPercent(List<Waiters> associates){..same..}
public boolean checkPercent(List<KitchenStaff> associates){..same..}
Run Code Online (Sandbox Code Playgroud)
我想要这个
public boolean checkPercent(List<could be any type> associates){..same..}
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以为所有不同类型的列表使用相同的代码(工作人员在它们中具有相同的值,因此它们没有任何不同)?
我正在使用带有EXT JS的Spring和hibernate使用tomcat在网页上填充EXT JS表单...我使用访问数据库的方法填充表并返回我的HQL语句
现在我尝试执行一个简单的JUnit测试来计算返回的记录数,但是当我在JUint测试中调用填充EXT JS表单的方法时,它会返回此感知...我不知道为什么
JUnit Test类
package com.fexco.helloworld.web;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.fexco.helloworld.web.dao.CustomerDaoImpl;
import com.fexco.helloworld.web.model.Customer;
/**
* Unit test for simple App.
* /
public class CustomerServiceTest {
@Autowired
private CustomerDaoImpl customerDaoImpl;
@Test
public void findAllCustomersTest() {
List<Customer> list = customerDaoImpl.findAllCustomers();
int numberInDatabase = list.size();
assertEquals(5, numberInDatabase);
}
}
Run Code Online (Sandbox Code Playgroud)
我的方法访问数据库
public List<Customer> findAllCustomers(){
List<Customer> list = getHibernateTemplate().find("from Customer");
return list;
}
Run Code Online (Sandbox Code Playgroud)
和我的方法调用访问数据库的方法
public List<Customer> returnAllCustomers(){
List<Customer> list = customerDaoImpl.findAllCustomers();
return list;
}
Run Code Online (Sandbox Code Playgroud)
你可以在这里看到表单使用与junit中相同的方法填充数据库中的项目(findAllCustomers()) …
我正在使用 Netbeans GUI Builder,我正在向我的表单中添加一个 JTree,因为 Netbeans 正在为 JTree 生成所有代码。
我想知道的是,Netbeans 中是否有一种方法可以将代码添加到生成的代码中......就像在Generated Code
它创建的部分的源视图中一样
jTree = new javax.swing.JTree();
Run Code Online (Sandbox Code Playgroud)
我想添加populateJTree.addNodes(null, folder)
它看起来像
jTree = new javax.swing.JTree(populateJTree.addNodes(null, folder));
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点
java ×12
swing ×4
hibernate ×3
spring ×3
jlist ×2
jtree ×2
netbeans ×2
spring-mvc ×2
api ×1
compilation ×1
directory ×1
extjs ×1
file-io ×1
filesystems ×1
html ×1
javascript ×1
jfilechooser ×1
junit ×1
list ×1
object ×1
oop ×1
rest ×1
safari ×1
sql-server ×1
textarea ×1