你能帮帮我吗?我有一个JDialog与一些文本字段,复选框和按钮.我希望当帧不再聚焦时,消失.所以我在JDialog中添加了一个焦点监听器,当焦点丢失时,我打电话给dialog.setVisible(false);.问题是,如果我点击复选框,文本字段或按钮,框架将失去焦点并消失.在用户点击其外部区域之前,我怎么能保持专注?
编辑:我指的"框架"是一个JDialog.我不使用Frame也不使用JFrame.所有组件都放在JDialog上.我希望它在没有聚焦时隐藏,但要保持专注,直到用户点击它的区域外.
我有一个包含JMenuBar的框架.如果用户单击"Logout"MenuItem,我将删除所有框架的内容并使用其他内容对其进行初始化.问题是,如果我打电话
parent.getContentPane().removeAll();
LoginActivity l = new LoginActivity(parent);
l.init();
parent.validate();
Run Code Online (Sandbox Code Playgroud)
框架获得了一些其他内容,但JMenuBar来自之前的"视图"它仍然在这里.我怎么能摆脱它?
我的应用基本上是一个照片浏览器.我的做法(不要评判我,我是java新手)是要ArrayList填充BufferedImages然后将图像添加到JList(向左).
这是我得到一个图像的方式:
private void getFullImage() {
BufferedImage im = null;
ImageReader imageReader = null;
try {
System.out.println("Loading "+original+"...");
String suffix = Utils.getFileExt(original.getName(), "jpg");
@SuppressWarnings("rawtypes")
Iterator readers = ImageIO.getImageReadersBySuffix(suffix);
imageReader = (ImageReader)readers.next();
imageReader.setInput(new FileImageInputStream(original));
im = imageReader.read(0);
imageReader.dispose();
} catch (Exception e)
{
e.printStackTrace();
}
this.img = im;
}
Run Code Online (Sandbox Code Playgroud)
然后,在我获取所有数据后,我会将图像添加到我的JList:
Vector vector = new Vector();
JPanel container = null;
PhotoPanel pp = null;
Photo p = null;
for(int i=0;i<files.length;i++)
{
p …Run Code Online (Sandbox Code Playgroud) 我希望在Android应用程序中禁用横向视图.我用过:
<activity android:name=".SomeActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
Run Code Online (Sandbox Code Playgroud)
它有效,但有一个小问题.如果我旋转屏幕,活动将重新开始,当它返回时,屏幕仍处于纵向模式.我希望我的应用程序完全忽略设备的位置.如果在旋转设备时活动重新开始(屏幕变黑几秒钟,然后活动再次显示为纵向模式),则禁用横向视图没有意义.
我想动态填充下拉列表.我会向服务器发出请求,从那里获取我的数据并根据我的数据(例如我会采取一些ID)我想使列表更大/更小.我在developer.android上找到的示例是静态的,因为列表中的名称是在strings.xml中编写的
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="planet_prompt">Choose a planet</string>
<string-array name="planets_array">
<item>Mercury</item>
<item>Venus</item>
<item>Earth</item>
<item>Mars</item>
<item>Jupiter</item>
<item>Saturn</item>
<item>Uranus</item>
<item>Neptune</item>
</string-array>
</resources>
Run Code Online (Sandbox Code Playgroud)
完整代码在这里.
我怎样才能调整图像大小并保持其纵横比?
这是我使用的方法:
private static BufferedImage resizeImage(BufferedImage originalImage,
int type) {
BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT,
type);
Graphics2D g = resizedImage.createGraphics();
g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);
g.dispose();
return resizedImage;
}
Run Code Online (Sandbox Code Playgroud)
该type变量:
BufferedImage original = ImageIO.read(new File(imagePath));
int type = original.getType() == 0 ? BufferedImage.TYPE_INT_ARGB
: original.getType();
Run Code Online (Sandbox Code Playgroud)
问题是一些图像被正确调整大小,但其他图像由于IMG_WIDTH和IMG_HEIGHT而失去了宽高比.
有没有办法获得原始图像尺寸,然后应用某种比例调整大小来维持调整大小的图像的纵横比?
我想创建一个iOS移动应用程序,它与我的Node.js Web应用程序进行通信.为了加密从移动设备发送到Web应用程序的数据,我决定使用AES 256加密,然后转换为base64.问题是我发现的所有Objective-C库都没有与Node.js相同的输出(对于相同的密码和输入文本).我真的不知道该怎么办......
以下是一些iOS库:
另外,对于Node.js平台,我尝试了这些库:
基于这个例子,我构建了我的:
var crypto = require('crypto');
var key = "onceuponatime";
var toCrypt = "Hello World!";
var output = '';
var decrypted = '';
var cipher = crypto.createCipher('aes256', key);
output += cipher.update(toCrypt, 'utf-8', 'base64');
output += cipher.final('base64');
console.log(output);
var deCipher = crypto.createDecipher('aes256', key);
decrypted += deCipher.update(output,'base64','utf-8');
decrypted += deCipher.final('utf-8');
console.log(decrypted);
Run Code Online (Sandbox Code Playgroud)使用FBEncryptor和我的Node.js例子我得到以下加密的base64字符串为我提供的输入:7TsBLBvS6A1iByn9OTkzWA==和mZ9cf4oklVN2ZnD0oQ0Tjw==.你能帮我找到一个解决方案,我会在iOS和Node.js上得到相同的加密字符串吗?谢谢.
是否有任何网站可以编写oracle sql代码,甚至可以构建一个小型数据库来运行,运行它并查看输出?我尝试过在网上搜索但除了W3Schools网站之外我找不到任何东西.
MPMoviePlayerController我正在尝试使用 a或 .在我的应用程序中播放短视频AVPlayer。问题是(因为我的视频没有任何声音)我不想干扰后台其他应用程序播放的声音。我尝试玩AVAudioSession:
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryAmbient withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
[audioSession setActive:YES error:nil];
Run Code Online (Sandbox Code Playgroud)
但我没有运气。视频开始播放后,背景音乐就会停止。我什至尝试将音频会话设置为非活动状态:
[[AVAudioSession sharedInstance] setActive:NO withOptions: AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:nil];
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,声音停止半秒,然后恢复,视频播放器停止播放。有什么方法可以实现我想要做的事情吗?谢谢。
有没有办法通过NSTimer将参数发送到选择器?
myTimer =[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(removeTheNote:) userInfo:nil repeats:NO];
- (void)removeTheNote:(NSString*)note
{
NSLog(@"Note %@ ----------- REMOVED!",note);
}
Run Code Online (Sandbox Code Playgroud)
我知道使用:
myTimer =[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(removeTheNote:myNote) userInfo:nil repeats:NO];
Run Code Online (Sandbox Code Playgroud)
不起作用,所以我问,有没有办法做到这一点?