我正在尝试开发一个LARP角色管理器,我在我的框架内,一个面板包含我想要使用CardLayout交换的所有窗口.这是我的ContainerPane代码.
public class ContainerPane extends JPanel {
private static final long serialVersionUID = -4799973935806714569L;
private JPanel deckOfPanes = null;
private PlayerManagerPane myPlayerManagerPane = null;
private GameManagerPane myGameManagerPane= null;
private CharacterManagerPane myCharacterManagerPane = null;
final static String CHANGETOCHARACTERMANAGERPANE = "Character Manager";
final static String CHANGETOPLAYERMANAGERPANE = "Player Manager";
final static String CHANGETOGAMEMANAGERPANE = "Game Manager";
public ContainerPane(EventListener myEventListener) {
myPlayerManagerPane = new PlayerManagerPane(myEventListener);
myGameManagerPane = new GameManagerPane(myEventListener);
myCharacterManagerPane = new CharacterManagerPane(myEventListener);
deckOfPanes= new JPanel(new CardLayout());
deckOfPanes.add(myCharacterManagerPane,CHANGETOCHARACTERMANAGERPANE);
deckOfPanes.add(myPlayerManagerPane,CHANGETOPLAYERMANAGERPANE);
deckOfPanes.add(myGameManagerPane,CHANGETOGAMEMANAGERPANE);
CardLayout cardLayout = …
Run Code Online (Sandbox Code Playgroud) 围绕堆栈交换我无法找到一个好的答案.我见过的类似问题中的大多数代码看起来都很庞大而且容易出错; 我不知道我是否犯了同样的错误.
我只有两个类(和一个接口),我的问题是我的JTable是空白的:
这是我的代码:
public class Launcher {
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
IViewManager.Util.getInstance();
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
public class ViewManager implements IViewManager {
JFrame frame = null;
JTabbedPane myListTabs = null;
ComicsListPane myComicsListPane = null;
public ViewManager(){
//Create and set up the window.
frame = new JFrame("My List Agregator");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Add the Tabbed pane for lists.
myListTabs = new JTabbedPane();
myComicsListPane = new ComicsListPane();
myListTabs.add(myComicsListPane);
myListTabs.setTitleAt(myListTabs.getTabCount()-1, "title");
frame.getContentPane().add(myListTabs);
//Display …
Run Code Online (Sandbox Code Playgroud) 可能重复:
List与ArrayList变量类型?
我HashSet
在我的程序中正如我所说:
Set<String> namesFilter = new HashSet<String>();
如果我这样开始,这在功能上有什么不同吗?
HashSet<String> namesFilter = new HashSet<String>();
我已经读过关于集合界面的这个,我理解接口(好吧,除了它们在这里使用).我已经从Effective Java中读到了这段摘录,我已经阅读了这个问题,但我觉得没有比这更聪明了.
Java中是否有最佳实践,如果是,为什么?我的直觉是,Set
在我的第一个例子中,它使铸造变得更容易.但话说回来,你只会投射到一个集合的东西,你可以通过重新构建它来转换它.
这主要是一个理论问题。下面的示例使我想到了它,但这可能不是最好的示例。请假设以下原因是具体的,暂时无法解决。
我正在运行的程序具有一个可选的调试框架,该框架在程序启动时创建,并且可以通过用户按按钮/键盘快捷方式使其可见。
我的问题是,由于我在EDT上的进程很长,如果它由于某种原因挂起或失败,我想立即查看,而不是等待该线程结束运行,以更新调试日志框架。
我的解决方案是让两个单独的GUI具有两个单独的EDT,并由一个单独的线程更新它们。
这可能吗,还是我做不到?我尚未找到任何可以向我展示如何使用的在线资源。我知道EDT应该是单线程的,但是如果我使线程不纠缠,我可以有两个吗?请?
我无法退出Vim,我点击逃跑并尝试:q:x:qx
没有其他问题正在运行,我正在运行Windows 8.
假设我有这个方法:
def is_root_task(self, root=None):
'''Returns true if the task is the root of a series of other tasks'''
super_tasks = self.dependency_sub_task.all()
if not root:
return not super_tasks.exists()
else:
return not super_tasks.exclude(task_id__exact=root.id).exists()
Run Code Online (Sandbox Code Playgroud)
我这样注册:
from django import template
from gantt_charts.models import Task
register = template.Library()
register.tag('is_root_task', Task.is_root_task)
Run Code Online (Sandbox Code Playgroud)
如何在 if 块(或类似块)内调用它?例如,假设我希望将其显示在我的页面中:
<ul>
{% for sub_task in task.sub_tasks %}
{% if is_root_task "sub_task" "task" %}
<li >
<p>{{sub_task.title}}</p>
<p>{{sub_task.description}}</p>
</li>
{% endif %}
{% empty %}
<li> No Sub-tasks</li>
{% endfor %}
</ul>
Run Code Online (Sandbox Code Playgroud)
我想将任务变量(root)和 …
我在交互式shell中测试了一些Django功能
这是我尝试探测这些对象,请注意最后的Nones列表
>>> [print(foo) for foo in CharacterSkillLink.objects.all() if foo.speciality]
Streetwise (Street Countdown) Roran
[None]
Run Code Online (Sandbox Code Playgroud)
并且具有更正统的列表理解:
>>> [print(foo) for foo in range(1,10)]
1
2
3
4
5
6
7
8
9
[None, None, None, None, None, None, None, None, None]
Run Code Online (Sandbox Code Playgroud)
九个Nones,都是连续的.
我为什么要这样做?
我已经将一些更改推送到了遥控器。现在我需要推送一些其他更改,这些更改应该包含在之前推送的提交中,但不知何故却没有。我可以简单地通过新提交推送更改来做到这一点,但现在我已经找到了标志--no-edit
并且--amend
如果我需要推送新的更改,但我需要一次提交新旧更改才能git commit --amend --no-edit
实现这一目标?
我正在查看的 html 看起来像这样:
document.querySelectorAll('h4#unique_id ~ h5 ~p +p +h5').forEach(title => console.log(title))
Run Code Online (Sandbox Code Playgroud)
<body>
<h4 id="unique_id"> foo bing bar </h4>
<p>some text</p>
<p>some text</p>
<p>some text</p>
<!-- selection should start here -->
<h5>title text 1</h5>
<p>some text</p>
<p>some text</p>
<p>some text</p>
<h5>title text 2</h5>
<p>some text</p>
<p>some text</p>
<p>some text</p>
<p>some text</p>
<h5>title text 3</h5>
<p>some text</p>
<p>some text</p>
<p>some text</p>
<p>some text</p>
<p>some text</p>
<p>some text</p>
<!-- and end here -->
<h4 id="randome_id_234353">title text</h4>
<p>some text I don't want</p>
<p>some text …
Run Code Online (Sandbox Code Playgroud)可能重复:
Java中的匿名代码块
我前几天(在SO上)了解到这一点
public method() {
someCode()
{
Object value = localCode();
doSomethingWith(value);
}
moreCode();
}
Run Code Online (Sandbox Code Playgroud)
是有效的Java,它使包含value
该区域的本地块,因此value
只存在于该块中.
这有什么实际用途吗?如果没有,为什么Java没有给出这个(愚蠢)使用的警告{}
?
我有一些代码,如下:
int batchPosition = new Integer(batchBegin);
for (batchPosition;batchPosition<=batchEnd;batchPosition++)
Run Code Online (Sandbox Code Playgroud)
但我在eclipse中得到了这个错误:
Syntax error, insert "AssignmentOperator Expression" to complete ForInit.
Run Code Online (Sandbox Code Playgroud)
我已经看过关于这个错误的关于SO的各种帖子,并用谷歌搜索但我无法弄清楚为什么不允许这样做.
是否可以创建一个密钥是Collection(任何类型的集合)的映射?
如果我在大多数常见的收藏品上尝试它,我被告知收藏品不能用于比较.
我一直在尝试为自定义集合编写compareTo函数,但我很挣扎.
要么我需要编写compareTo,要么我需要找到一个接受地图接受的集合/集合的预制地图.
如何在地图上将集合用作关键字?我已经查看了Stack溢出,我已经多次搜索过这个问题,但我从来没有找到一个可靠的解决方案!
我想这样做的原因是我在Java中编写了一个模拟卡改组的'shuffle'模拟.我希望能够计算特定手(建模为集合)出现的次数.它看起来像这样:
H4,C3,D2: 8
H9,D6,S11: 10
......
Run Code Online (Sandbox Code Playgroud) 我正在开发一个java程序,其中我正在使用一大类Class实例.我必须为数组的每个对象进行一些计算(使用它的Class方法).当我使用Arrays.Sort或其他方法对数组进行排序时,我注意到计算时间的增加以执行我的计算,即排除进行排序的时间!
如果我对Arrays.sort函数进行注释,则在其他计算之前,计算时间约为1或2毫秒,而取消注释则增加到5或6毫秒.
我必须为大量的步骤(甚至300,000)做这项工作,所以增量会改变很多我的表现.
对这种奇怪的行为有什么解释吗?
java ×8
collections ×2
swing ×2
block ×1
comparable ×1
constructor ×1
css ×1
django ×1
for-loop ×1
generics ×1
git ×1
git-amend ×1
github ×1
html ×1
javascript ×1
jtable ×1
layout ×1
map ×1
performance ×1
python ×1
python-3.x ×1
sorting ×1
vim ×1