我想动态添加按钮数组.我试过这样的:
this.pack();
Panel panel = new Panel();
panel.setLayout(new FlowLayout());
this.add(panel);
panel.setVisible(true);
for (int i = 0; i < Setting.length; i++) {
for (int j = 0; j < Setting.width; j++) {
JButton b = new JButton(i+"");
b.setSize(30, 30);
b.setLocation(i * 30, j * 30);
panel.add(b);
b.setVisible(true);
}
}
Run Code Online (Sandbox Code Playgroud)
但没有得到任何东西,我犯了什么错误?
我有jFrame类"选择",我有一个按钮,当我按下按钮时,这应该发生:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
structure.Setting s = new Setting(8, 8, 3, 1, 1);
Game g = new …
Run Code Online (Sandbox Code Playgroud) 背景
我有一个Root元素类,它包含类的变量java.sql.Timestamp
,我希望JAXB从该变量创建xml元素.
我试过了什么
import java.sql.Date;
import java.sql.Timestamp;
import javax.xml.bind.annotation.adapters.XmlAdapter;
public class TimestampAdapter extends XmlAdapter <Date, Timestamp> {
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)public Date marshal(Timestamp v) { return new Date(v.getTime()); } public Timestamp unmarshal(Date v) { return new Timestamp(v.getTime()); }
}
@XmlJavaTypeAdapter(TimestampAdapter.class)
public java.sql.Timestamp getEndDate(){if(endDate == null)
retrieveInfo();
return endDate;
}
问题
我仍然得到这个例外
java.sql.Date does not have a no-arg default constructor.
Run Code Online (Sandbox Code Playgroud)
此外,我已经检查了这个线程,但它正在谈论String到TimeStamp,而不是我的情况.
任何帮助,将不胜感激.
编辑
这个变量在类OrderStatus
,我把它从类OrderImpl
这样
@Override
@XmlElement(name = "Status", type = OrderStatus.class)
public OrderStatus …
Run Code Online (Sandbox Code Playgroud) 我有一个包含许多子查询的查询,其中还包括一些子查询.我想知道SPARQL查询中的values子句的范围.它是否也归结为子查询?
如果我在子查询中定义了一个values子句,并在父查询中使用了相同的变量,那么该变量是否只具有子查询中指定的值?(反过来呢?)
我查看了SPARQL 1.1规范,但我发现以下内容,似乎没有回答我的问题:
VALUES数据块可以出现在查询模式中或SELECT查询的末尾,包括子查询.
我有这个代码:
System.err.print("number of terms = ");
System.out.println(allTerms.size());
System.err.print("number of documents = ");
System.out.print("number of documents = ");
Run Code Online (Sandbox Code Playgroud)
我认为结果应如下:
number of terms = 10
number of documents =1000
Run Code Online (Sandbox Code Playgroud)
但结果是
10
1000
number of terms = number of documents =
Run Code Online (Sandbox Code Playgroud)
为什么,以及如何解决它?
在我的页面上,我想要在鼠标移过时突出显示的许多部分.这可以使用onmouseover
和完成onmouseout
.我有超过100个部分,我不认为在每个部分调用方法是非常有效的.像这样.
<li id="1" onmouseover="h(1)" onmouseout="h(1)">
<label>1</label>
</li>
<li id="2" onmouseover="h(2)" onmouseout="h(2)">
<label>2</label>
</li>
<li id="3" onmouseover="h(3)" onmouseout="h(3)">
do something
</li>
...
<li id="4" onmouseover="h(4)" onmouseout="h(4)">
do something
</li>
Run Code Online (Sandbox Code Playgroud)
我希望在Javascript中得到这个答案,因为我不知道jQuery.
我想当用户打开应用程序播放歌曲时,当歌曲结束时,新的活动将被触发,我放一个跳过按钮,允许用户停止歌曲并转到下一个活动,这是代码
timer = new Thread() {
public void run() {
try {
sleep(13000);
} catch (InterruptedException e) {
// TODO: handle exception
} finally {
Intent openStartingPoing = new Intent(
"com.localizedbasedcompetition.SIGNIN");// action
// name
startActivity(openStartingPoing);
}
}
};
timer.start();
Run Code Online (Sandbox Code Playgroud)
这是跳过按钮的onclick
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.bSplashSkip:
timer.stop();
Intent openStartingPoing = new Intent(
"com.localizedbasedcompetition.SIGNIN");// action name
startActivity(openStartingPoing);
break;
default:
break;
}
}
Run Code Online (Sandbox Code Playgroud)
并且该代码工作正常,我的意思是,如果我单击跳过按钮,歌曲停止并且新活动被推出,但我的问题是即使也是好的,我有一个例外(但应用程序仍然有效)并且应用程序是
07-05 13:34:19.687: E/global(26114): Deprecated Thread methods are not supported. …
Run Code Online (Sandbox Code Playgroud) 我想在listview下面放一个linearlayout,如果我把它放在listview上面我得到一个异常并且活动突然停止工作,当我把它放在listview下它没有出现时,我做错了什么?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/lvRestaurants"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ListView>
<LinearLayout
android:id="@+id/llButtons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/bDone"
android:layout_width="153dp"
android:layout_height="match_parent"
android:text="Done" />
<Button
android:id="@+id/bCancel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Cancel" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 嗨,所以这里是用于解析Swift 2中的JSON文件的样板代码.我以前使用它并且它可以工作但是由于某种原因它在最新版本的Xcode 7.1和Swift 2中被破坏了.有关这个人的任何想法?错误是"参数标签"(contentsOfFile:,options:,error :)'与任何可用的重载都不匹配"
import Foundation
extension Dictionary {
static func loadJSONFromBundle(filename: String) -> Dictionary<String, AnyObject>? {
if let path = NSBundle.mainBundle().pathForResource(filename, ofType: "json") {
var error: NSError?
let data = NSData(contentsOfFile: path, options: NSDataReadingOptions, error: &error)
if let data = data {
let dictionary: AnyObject? = NSJSONSerialization.JSONObjectWithData(data,
options: NSJSONReadingOptions(), error: &error)
if let dictionary = dictionary as? Dictionary<String, AnyObject> {
return dictionary
} else {
print("Level file '\(filename)' is not valid JSON: \(error!)")
return nil
}
} else …
Run Code Online (Sandbox Code Playgroud) 是否可以将NSURLSession发送的请求记录到控制台?我遇到了身份验证问题,如果我无法查看请求,则无法进行调试
我正在尝试将数据传递UITableview
给另一个UITableview
,当我按下时我成功传递数据cell
但是当我按下导航栏的后退按钮时我无法传回数据; 我已经尝试过全局变量来解决这个问题,但由于我将这些变量的日期存储在数据库中,这给我带来了很多问题,因为它强制执行所有存储的提醒以保存相同的数据,我可以做一些技巧解决这个问题,但我们都知道全局变量是不好的做法而且OOP
都不确认MVC
,问题是如何使用Prepare for segue
函数传回数据; 请注意,表视图是静态的而不是动态的.
如果你问的是我试图传递的数据是星期几,例如选择星期五和星期六时它会将真值发送回前一个视图,如果取消选择星期五和星期六,则会将错误值发送回上一个视图
那我怎么解决这个问题呢?
提前致谢