我有一个基本的应用程序,其中包含文本输入、旋转器输入和第二个旋转器输入,其数组取决于“选项”菜单中更改的设置。
目前,当我在应用程序中按 Home 或按 Return 时,我要么返回桌面,要么循环返回最近输入的旧输入。
如何防止我的应用程序打开自身的多个实例,以便在任何给定时间只有一个实例运行,然后如何保存输入到输入中的数据以及在选项菜单中选择的设置?
我对 Java 有点陌生,所以如果这是一个简单的问题,我深表歉意。
以下代码呈现具有可互换坐标的僵尸.唯一的问题是我必须自己复制代码并为每个僵尸创建新的坐标变量.有什么方法可以创建变量的副本,所以我只需要有一个方法可以为多个僵尸提供三个方法和三个独立变量的三个僵尸吗?
int zombieyCord;
int zombiexCord;
-(void)renderZombie
{
NSBezierPath * path = [NSBezierPath bezierPath];
[path setLineWidth:4];
NSPoint center = {zombieyCord,zombiexCord};
[path moveToPoint: center];
[path appendBezierPathWithArcWithCenter:center
radius:5
startAngle:0
endAngle:360];
[[NSColor greenColor] set];
[path fill];
[[NSColor greenColor] set];
[path stroke];
}
Run Code Online (Sandbox Code Playgroud)
编辑:
产卵很棒,效果很好,但我希望僵尸能够正常运动.之前,代码是该方法是在玩家移动时调用的.这不再有效,因为我必须在方法中调用一个整数.
+(void)entityZombie:(int)zombiexCord andY:(int)zombieyCord
{
/* Handle Zombie Movement*/
if (xcord != zombiexCord || ycord != zombieyCord)
{
if (xcord > zombiexCord){zombiexCord=zombiexCord+1;}
if (xcord < zombiexCord){zombiexCord=zombiexCord-1;}
if (ycord < zombieyCord){zombieyCord=zombieyCord-1;}
if (ycord > zombieyCord){zombieyCord=zombieyCord+1;}
/* Handle Zombie Render*/
NSBezierPath * path …Run Code Online (Sandbox Code Playgroud) 我正在尝试同时运行2个项目play framework,但收效甚微.这是在尝试运行第二个实例时弹出的错误:
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_E
RROR_TRANSPORT_INIT(197)
Run Code Online (Sandbox Code Playgroud)
我试图改变http一个端口9000和对方9001,但还是同样的错误.关于如何让这些多个实例运行的任何想法?提前致谢.
我的节目是关于一家超市.我在delivery()方法中创建了一个名为b1的JButton.我希望当用户按下按钮b1时关闭JFrame窗口.但不幸的是我不知道该怎么做.请帮忙.以下是我的程序的delivery()方法:
public static void delivery()
{
JFrame f = new JFrame("Name");
f.setVisible(true);
f.setSize(600,200);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setLocation(700,450);
JPanel p = new JPanel();
final JLabel l = new JLabel("Enter your name: ");
final JTextField jt = new JTextField(20);
JButton b1 = new JButton("Ok");
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
input = jt.getText();
}
});
p.add(b1);
p.add(l);
p.add(jt);
f.add(p);
String b = JOptionPane.showInputDialog(null, "Please enter your address in one single line:");
JOptionPane.showMessageDialog(null, "The ordered stuff will be delivered to " +input+ " …Run Code Online (Sandbox Code Playgroud) 我有一个带有两个表变量的存储过程(@temp和@ temp2).
如何从两个临时表中选择值(两个表变量都包含一行)并将它们全部插入一个表中?
我尝试了以下但这没有用,我得到的错误是SELECT和INSERT语句的数量不匹配.
DECLARE @temp AS TABLE
(
colA datetime,
colB nvarchar(1000),
colC varchar(50)
)
DECLARE @temp2 AS TABLE
(
colD int
)
Run Code Online (Sandbox Code Playgroud)
...
INSERT INTO MyTable
(
col1,
col2,
col3,
col4
)
SELECT colD FROM @temp2,
colA FROM @temp,
colB FROM @temp,
colC FROM @temp
Run Code Online (Sandbox Code Playgroud)
蒂姆,非常感谢你提供的任何帮助.
sql sql-server multiple-instances multiple-tables insert-into
问题的关键在于:我有两个JFrame,让我们说一个大JFrame Foo和更小的JFrame Baz.我有两个同时打开,有没有办法让Baz永远隐藏在"Foo"背后?现在当Baz"在前面"而我点击Foo时,Baz消失在Foo后面,我不想发生这种情况.
我正在尝试在一个 docker-compose 中运行两个 MongoDB。由于我想在每个数据库中存储不同的数据,我需要通过不同的端口来区分它们。如果我运行以下 docker-compose,端口 27017 一切正常,但我无法访问端口 27018。在控制台中,两个服务的一切看起来都一样,只有端口 27018 上的服务缺少以下日志:
NETWORK [initandlisten] 等待端口 27017 上的连接(显示端口 27017)
当我尝试在浏览器中访问这两项服务时,端口 27017 上的一项有效,而 27018 上的一项无效。
如果有人能帮助我解决这个问题,我很高兴。很长一段时间以来一直在努力。谢谢!
这是我的代码:
version: "3"
services:
mongo:
image: mvertes/alpine-mongo:4.0.1-0
volumes:
- mongoDBvolume:/data/db
ports:
- "27017:27017"
testmongo:
image: mvertes/alpine-mongo:4.0.1-0
command: mongod --port 27018
volumes:
- mongoDBvolume:/data/testdb
ports:
- "27018:27017"
volumes:
mongoDBvolume:
driver: local
Run Code Online (Sandbox Code Playgroud) 当我在iPhone上使用NSXMLParser解析XML时,我有一个奇怪的问题.启动应用程序时,我想预先加载4个表视图,这些视图在后台由RSS-Feeds填充.
当我逐个启动表视图时,而不是加载,解析和显示所有的工作,如魅力.但是当我尝试一次(同时)初始化所有视图时,看起来XML-parser-instances互相干扰.不知何故,来自一个XML-Feed的数据被"广播"到其他不属于的xml-parser实例中.示例:有一个"团队成员"项目,"这是我的名字".当这个错误发生时,添加了另一个xml-feed的字符串,即导致:"这是我的名字58",其中58是来自另一个视图的图表位置.在另一个例子中,"58"似乎错过了.
在我看来,由于NSXMLParser委托方法,这个错误发生了:
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if (!currentStringValue) {
currentStringValue = [[NSMutableString alloc] initWithCapacity:50];
}
[currentStringValue appendString:string];
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,"通过巧合"字节被附加到不属于它们的字符串.
奇怪的是,NSXMLParser的每个实例都是唯一的,有自己独特的委托,附加到自己的ViewController.每个解析请求产生它自己的后台任务,它有自己的(也是唯一命名的)自动释放池.
我在ViewController中调用NSXMLParser:
// prepare XML saving and parsing
currentStringValue = [[[NSMutableString alloc] initWithCapacity:50] retain];
charts = [[NSMutableArray alloc] init];
NSURL *url = [[NSURL alloc] initWithString:@"http://(SOME XML URL)"];
xmlParser = [[[NSXMLParser alloc] initWithContentsOfURL:url] retain];
//Set delegate
[xmlParser setDelegate:self];
//loading indicator
progressWheel = [[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(150.0,170.0,20.0,20.0)] autorelease];
progressWheel.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
[self.view addSubview:progressWheel];
[progressWheel startAnimating];
// start loading and …Run Code Online (Sandbox Code Playgroud) 我有一个JFrame,我有10个JLabel会打开新的JFrame.这JFrame是同样的,将在10开的标签,但如何禁用根JFrame时,另一个JFrame是开放并启用根JFrame当新的帧是已结束?请问我能提出您的意见吗?
我实际上正在开发一个显示许多帧的java项目,当我们点击一个按钮然后我们转到相应的框架......问题是第一帧始终保持可见.
我试过f1.setVisible(false); 在执行的动作中,但同样的问题仍然存在.
java ×5
swing ×4
jframe ×3
android ×1
background ×1
billing ×1
docker ×1
http ×1
insert-into ×1
iphone ×1
jbutton ×1
methods ×1
mongodb ×1
nsxmlparser ×1
objective-c ×1
save ×1
sql ×1
sql-server ×1
xml ×1