我想控制按钮的大小,我使用方法setBounds但是没有变化,这是我的代码
public class levels extends JFrame implements ActionListener{
//Variables
private static JLabel chooseLevel;
private static JButton easyPuzzle;
private static JButton mediumPuzzle;
private static JButton hardPuzzle;
// End Of Variables
Run Code Online (Sandbox Code Playgroud)
这主鳕鱼
public static void main(String[]args){
levels level = new levels();
level.setBounds(400, 190, 450, 450);
level.setVisible(true); // frame is visible
level.setResizable(false); // not Resizable frame
level.setTitle("Puzzle Number : New Game"); // Title Of the frame
Run Code Online (Sandbox Code Playgroud)
容器添加组件
Container cN = level.getContentPane(); // Container to add components for farme 1
GridLayout gN = new …
Run Code Online (Sandbox Code Playgroud) 我完全转换为自由职业者,我想在版本控制系统中维护我的客户端代码,理想情况是Git,SVN和Mercurial什么是最好的?
我想把一个小游戏扔在一起并把它放到网上.这将是多人游戏(理想情况下它将是MMO,但它是一个侧面项目,所以我会满足于MO hehe),内容相当不重要.我打算用Java编写游戏(服务器和客户端).
我正在考虑我可靠的选择来获取可靠的信息.JMS对此有用吗?我需要更多(如果是,那是什么)?还有更好的选择吗?
我过去做了几场比赛,但没什么多人游戏.我使用的是一个使用JMS的应用程序,并且有很多教程,所以这就是为什么我认为它会起作用......但我真的很开放.
谢谢!
编辑:看来我有很多东西要学习JMS.也许我的问题应该改为:"JMS的哪些实现最能满足我对MMO的目的?"
迄今为止的标准:
所以我的查询有问题,我真的不明白在哪里.注释放在语法错误的位置.查询要大得多,我试图缩短它以进行有效但更整洁的查询.
这是使用odbc连接到Progress数据库.我被告知它使用严格的SQL-92.
SELECT itemcust."item-cust",
itemcust."cust-no",
corptreeCust.code
FROM pub."item-cust" itemcust
JOIN pub.customer cust
left join pub.salesstructcustomer struct
on ( struct."corp-cust-type" = cust."corp-cust-type"
and struct."corp-cust-num" = cust."corp-cust-num"
)
left join pub.corptree corptreeCust
on ( corptreeCust.uid = struct.corptreeid /* program says SQL Syntax error here */
and corptreeCust.category = 'store'
)
where ( itemcust."in-entity" = {$entity} or itemcust."in-entity" = '*')
and itemcust."item-no" = {$itemno}
and ( itemcust."cust-no" = {$custno} or itemcust."cust-no" = '*')
and cust."cust-no" = {$custno}
Run Code Online (Sandbox Code Playgroud)
谢谢!
如果有人可以帮我解决以下问题,我会很高兴.下面的方法假设返回一个数组,其第i个条目是int i出现在数组a中的次数.方法名称使用此方法.绘制数组a中的数据直方图.
public static int histogram(int M, int[] a){
int[] b = new int[M];
for (int i = 0; i < M; i++){
int w = 0;
for (int j = 0; j < a.length; j++){
if (a[j] == i){
w++;
}
}
b[i] = w;
}
return b;
}
Run Code Online (Sandbox Code Playgroud)
对我来说代码是正确的 - 它可能是错的 - 我无法测试它,因为我有一个错误,这真的让我烦恼.
Histogram.java:22:找到不兼容的类型:int [] required:int return b;
1)上面的意思是什么?例如在互联网和我的手册中,他们也只使用"返回b;" 将数组返回主程序.
2)返回功能究竟如何工作?我是否可以使用以下代码打印数组b的值?因为此刻我得到一个错误,因为数组b没有在main中初始化...我认为如果错误1被整理出来,错误就会消失.我是JAVA的新手,所以我真的不知道 - 编程新手.
for (int x = 0; x < M; x++){
System.out.printf("%d ", b[x]);
}`
Run Code Online (Sandbox Code Playgroud)
3)我是否可以在histogram()方法中打印值?要回答的问题是使用直方图值"返回"数组.
如果你能提供帮助,真的很高兴...... …
给定两个指向不同方向的三维向量。我希望第一个向量能够向第二个向量改变方向一定的度数。计算这个新向量的公式或算法是什么。
例如,一艘宇宙飞船(这是一个宇宙飞船模拟器)指向(2,3,3)的方向。船现在将向 (2,-3,-2) 的矢量方向改变方向 20 度。新的载体是什么。它不是沿轴旋转,而是与两个向量成直角。
嗨,我在 CodeBlocks IDE 中使用 C++ 和 OpenCV 制作了一个人机界面来使用手指控制鼠标 http://www.youtube.com/watch?v=-q5aXTg0pVE 我想在像荣誉勋章这样的 3D 游戏中使用它
首先我使用 SetCursorPos(x,y) 它不起作用所以我切换到 SendInput 和 mouse_event。他们确实解决了角色开始指向所有随机方向并自行改变方向的错误。
我应该使用directinput,因为游戏使用directx。如果是这样怎么办?我已经尝试了很多教程,但都在谈论如何从鼠标获取数据,而不是如何插入鼠标流我使用了绝对定位和相对定位,但都失败了角色表现得很奇怪
我有一个包含18个对象的数组,并且数组被分配为包含25个对象(其余7个对象为null以供将来使用).我正在编写一个打印出所有非空对象的程序,但是我正在运行NullPointerException
,我无法弄清楚如何绕过它.
当我尝试这个时,程序崩溃了Exception in thread "main" java.lang.NullPointerException
:
for(int x = 0; x < inArray.length; x++)
{
if(inArray[x].getFirstName() != null)//Here we make sure a specific value is not null
{
writer.write(inArray[x].toString());
writer.newLine();
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试这个时,程序运行,但仍然打印空值:
for(int x = 0; x < inArray.length; x++)
{
if(inArray[x] != null)//Here we make sure the whole object is not null
{
writer.write(inArray[x].toString());
writer.newLine();
}
}
Run Code Online (Sandbox Code Playgroud)
有人能指出我正确的方向来处理数组中的空对象吗?所有帮助表示赞赏!
假设我有一个Player类:(忽略访问修饰符)
@javax.xml.bind.annotation.XmlRootElement
class Player {
Long id;
String name;
String secret;
}
Run Code Online (Sandbox Code Playgroud)
我也可能在王国周围有城堡
@javax.xml.bind.annotation.XmlRootElement
class Kingdom {
Long id;
String name;
Player owner;
}
Run Code Online (Sandbox Code Playgroud)
现在,当我将王国对象吐到json供UI消费时,玩家对象也随之消失.这很好,如果你不知道它是友好还是敌人,它就不会有用.但最糟糕的是秘密变量也被释放了.是否可以注释我的秘密变量以防止它被封送?
我有一个有效的正则表达式: ABC-[0-9]+
我也有一个正则表达式: DEF-[0-9]+
但我不知道如何将两者结合起来,所以它们都会匹配它们
我试过ABC-[0-9]+ | DEF-[0-9]+
但它没有真正起作用......
如果重要的话,这一切都在Java正则表达式中.
我是Java的初学者,正在寻求帮助.
所以我用Java制作了这个二叉树,我应该实现一个方法,按顺序对所有元素进行排序并将它们转换为字符串.它应该看起来像前."[1,2,3,4]".我使用StringBuilder来做到这一点.
我的方法代码看起来像这样:
/**
* Converts all nodes in current tree to a string. The string consists of
* all elements, in order.
* Complexity: ?
*
* @return string
*/
public String toString() {
StringBuilder string = new StringBuilder("[");
helpToString(root, string);
string.append("]");
return string.toString();
}
/**
* Recursive help method for toString.
*
* @param node
* @param string
*/
private void helpToString(Node<T> node, StringBuilder string) {
if (node == null)
return; // Tree is empty, so leave.
if …
Run Code Online (Sandbox Code Playgroud) 如果我在 Java 中有一个具有不可变成员的类,我会这样做:
class MyClass {
private final String name;
private final int id;
myClass(String name, int id) {
this.name = name;
this.id = id;
}
String getName() { return name; }
int getId() { return id; }
}
Run Code Online (Sandbox Code Playgroud)
在 Progress-4GL 中,您通常会看到这样的内容:(请不要讲匈牙利符号。我也讨厌它,但它在 Progress 社区中很常见,所以我只接受它。)
CLASS MyClass :
DEFINE VARIABLE mcName as CHARACTER NO-UNDO.
DEFINE VARIABLE miId as INTEGER NO-UNDO.
CONSTRUCTOR PUBLIC MyClass(INPUT ipcName AS CHARACTER,
INPUT ipiId AS INTEGER):
ASSIGN mcName = ipcName
miId = ipiID.
END. /* constructor(char,int)*/
END …
Run Code Online (Sandbox Code Playgroud) 我有一个文件副本的片段,如下所示:
<echo message="Root = ${original.src.root}" />
<copy todir="${source.root}">
<fileset dir="${original.src.root}"/>
</copy>
Run Code Online (Sandbox Code Playgroud)
现在,让我们说${source.root}
是"d:/build/src"
和${original.src.root}
现在"d:/projects/myproj/src"
.
我收到一条消息,上面写着"D:\ projects\myproj\scripts\build.xml:224:D:\ projects\myproj\scripts \"D:\ projects\myproj\src"不存在.
当然,我的脚本目录中没有src目录.当我执行echo消息时,它表示我的original.src.root
变量已正确设置.那么为什么要尝试引用基于绝对路径的基础?