我正在尝试使用 JPanel 做类似“生命游戏”的事情,问题是它出现在屏幕的左上角。我的问题是如何使其屏幕居中。PS我还尝试创建JFrame并向其中添加JPanel,但它只是分别创建了JFrame和JPanel。这是代码:
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.JPanel;
public class Animation extends JPanel implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private Cell[][] cellMatrix;
private Options op;
Animation(Options received) {
this.op = received;
this.cellMatrix = new Cell[op.getNumberOfCells()][op.getNumberOfCells()];
this.setBackground(op.getBackGroundColour());
}
Timer time = new Timer(5,this);
public void paintComponent(Graphics g) {
super.paintComponent(g);
for (int i = 0; i < op.getNumberOfCells() ; i++) {
for(int j = 0; j < op.getNumberOfCells(); j++) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用有角材料的小吃栏,但遇到了一个问题 - 小吃栏没有出现在屏幕的按钮上,而是出现在需要它的按钮下方。发生的另一件事是,它还将小吃店中的文本放在我的页面上。
这是我使用的代码:
Snackbar.ts
import { Component, OnInit } from '@angular/core';
import {MdSnackBar} from '@angular/material';
@Component({
selector: 'app-snack-bar',
templateUrl: './snack-bar.component.html',
styleUrls: ['./snack-bar.component.css']
})
export class SnackBarComponent implements OnInit {
constructor(public snackBar: MdSnackBar) {}
ngOnInit() {
}
openSnackBar() {
this.snackBar.open("Hello World","action",{duration: 500});
}
}
Run Code Online (Sandbox Code Playgroud)
Snackbar.html
<button md-button (click)="openSnackBar()" aria-label="Show an example snack-bar">
Click me
</button>
Run Code Online (Sandbox Code Playgroud)
应用程序组件.ts
import { Component } from '@angular/core';
import { SnackBarComponent } from './components/snack-bar/snack-bar.component';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent { …Run Code Online (Sandbox Code Playgroud) 我对 Django 应用程序中的模型表单之一进行了如此更改 - 我为用户添加了新的输入字段。然后我测试了环境的变化,一切正常。然后我提交更改并将其推送到远程存储库。我在 AWS 上运行的生产服务器上提取了更改。我pkill -f runserver在终端中运行以重新启动服务器,但是更改没有发生。只有有关 html 标签的更改可见(新标签等)。不存在的更改来自模型来源:用户的新输入字段 - 这些更改在模板页面中完全丢失。什么可能导致这种行为?
在我的应用程序中,我只想在可以访问互联网的情况下拨打网络电话。
注意:我连接到没有互联网的 WiFi 点
我想测试互联网是否可用。我尝试使用这里描述的可达性,我也尝试了一个更简单的解决方案,如这里描述
问题在于 Reachability 会返回 Internet 可达的信息,而当它不可达时。另一种解决方案需要太多时间才能做出响应。我试图为请求和会话设置超时间隔,但它被忽略了。
如果我连接到没有互联网的 wifi,如何测试互联网可达性?
这是我使用的一些代码:
- (void) postAsyncTaskWithUrl:(NSString*)urlString
andType:(NSString*)requestType
andToken:(NSString*)token
andPropertiesObject:(id)propObject
urlEncoded:(BOOL)isUrlEncoded
withSuccess:(nullable void(^)(id _Nullable))success
andFailure:(nullable void(^)(id _Nullable))failure
{
internetReachableFoo = [Reachability reachabilityWithHostname:@"www.google.com"];
__weak typeof(self) weakSelf = self;
// Internet is reachable
internetReachableFoo.reachableBlock = ^(Reachability*reach)
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlSt];
[request setTimeoutInterval:20]; //Ignored ... WHY?
NSURLSessionConfiguration *sessionConfigurations = [NSURLSessionConfiguration defaultSessionConfiguration];
[sessionConfigurations setTimeoutIntervalForRequest:20]; //Ignored ... WHY?
[sessionConfigurations setTimeoutIntervalForResource:20]; //Ignored ... WHY?
// NSURLSession *session = [NSURLSession sharedSession]; …Run Code Online (Sandbox Code Playgroud) nsurlrequest reachability ios nsurlsession nsurlsessionconfiguration
angular ×1
django ×1
ios ×1
java ×1
jframe ×1
jpanel ×1
nsurlrequest ×1
nsurlsession ×1
production ×1
reachability ×1