问题列表 - 第29962页

Mac OS X上的Java 6硬件加速

我有一个Java应用程序,我写了负载了TTF字体并使用来自Graphics2D的束带方法.调用此方法与x和y位置每次使文本举动改变每隔50ms.当我在Windows上运行的程序,我得到0-1%的CPU使用率,但在Mac上,我得到约75%的使用率.这Windows机器确实有一个更好的CPU,但没有办法,应该有那么大的差别.我认为这与硬件加速有关,我想知道如何启用它.我发现了一些Mac特定的Java属性,但它们都没有降低我的CPU使用率.有关如何在OS X上提高Java 2D性能的任何想法?谢谢.

编辑1:我认为这些属性会有所帮助,但他们没有.

System.setProperty("sun.java2d.opengl", "true"); System.setProperty("apple.awt.graphics.UseQuartz","true"); System.setProperty("apple.awt.graphics.EnableQ2DX","true");

EDIT2:您可以下载该项目的源和字节代码在这里:http://drop.io/ExampleScreenSaver

编辑3:由于drop.io不再存在,我将项目上传到Google Code.现在您无需下载即可浏览代码.我仍然不知道如何处理这个问题所以任何帮助将不胜感激.

java macos acceleration

5
推荐指数
1
解决办法
1768
查看次数

调用new和getInstance()之间的区别

呼叫Class.getInstance()等同于new Class()?我知道后者需要构造函数,但是怎么getInstance()办?谢谢.

java abstract-class

14
推荐指数
3
解决办法
4万
查看次数

循环穿过孩子

基本上,有没有办法通过子元素"循环".

即:

<ul>
<li>some text</li>
<li>some more text</li>
<li>even more text</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

我想从第一个文本中获取文本<li>,执行一些操作,然后继续下一个和下一个操作,直到我完成所有子元素.

这可能吗?

javascript jquery cycle

4
推荐指数
1
解决办法
1836
查看次数

NSFetchedResultsController索引超出边界

我正在使用NSFetchedResultsController来显示表视图中的项目:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [[self.fetchedResultsController fetchedObjects] count];
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"TagCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];;
    }

 Tag *tag = [self.fetchedResultsController objectAtIndexPath:indexPath];
 cell.textLabel.text = tag.name;

    return …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch core-data uitableview nsfetchedresultscontroller

6
推荐指数
3
解决办法
1万
查看次数

当我在JOptionPane.showMessageDialog中单击OK按钮时,Java程序退出

当我单击second.java程序中的OK按钮时,程序退出该程序.我希望它不要退出(因为有一个线程在运行).我尝试删除setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE).

alt text http://i47.tinypic.com/du335.jpg



import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class second extends JFrame implements ActionListener {

JLabel enterName;
JTextField name;
JButton click;
String storeName;

public second(){

    setLayout(null);
    setSize(300,250);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    enterName = new JLabel("Enter Your Name: ");
    click = new JButton("Click");
    name = new JTextField();
    enterName.setBounds(60,30,120,30);
    name.setBounds(80,60,130,30);
    click.setBounds(100,190,60,30);
    click.addActionListener(this);
    add(click);
    add(name);
    add(enterName);

}

public void actionPerformed(ActionEvent e) {

    if(e.getSource() == click) {

        storeName = name.getText();
        JOptionPane.showMessageDialog(null, …
Run Code Online (Sandbox Code Playgroud)

java jframe joptionpane

0
推荐指数
1
解决办法
2万
查看次数

'%p'和'my%p'之间的区别?

% %p = ('option1' => 'Option 1', 
% 'option2' => 'Option 2', 
% 'option3' => 'Option 3'
% );
    <select name="killer_feature" id="killer_feature" class="select">
% foreach (keys %p) {
% my $selected = param('killer_feature') && param('killer_feature') eq $_ ? 'selected="selected"' : '';
% if (!param('killer_feature') && $_ eq 'option2') { $selected = 'selected="selected"' }
    <option value=" <%=$_%>" <%= $selected %>>
        <%= $p{$_} %>
    </option>
% }
    </select>
Run Code Online (Sandbox Code Playgroud)

上面的代码通过返回'内部服务器错误'来破坏应用程序,但是如果我轻松编辑第一行% my %p(我试过它,因为其他一些控件都有这种格式)它可以工作,我想知道两者之间的区别.

它是一个基于Mojolicious Web框架的perl应用程序.

非常感谢!

perl mojo mojolicious

3
推荐指数
1
解决办法
468
查看次数

为什么我的表单身份验证票证到期如此之快?

我在ASP.NET应用程序中使用表单身份验证.我将其配置FormsAuthenticationTicket为在1年后到期,但实际上在1小时左右后到期.我无法弄清楚为什么.

以下是登录过程中涉及的所有代码:

public static bool Login(int id)
{
    try
    {
        string securityToken = UserHelper.AuthenticateUser(id);

        DateTime expiryDate = DateTime.Now.AddYears(1);
        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
             1, id.ToString(), DateTime.Now, expiryDate, true,
             securityToken, FormsAuthentication.FormsCookiePath);

        string encryptedTicket = FormsAuthentication.Encrypt(ticket);
        HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
        cookie.Expires = expiryDate;

        HttpContext.Current.Response.Cookies.Add(cookie);

        return true;
    }
    catch
    {
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)

Web.config文件:

<system.web>
    <machineKey validationKey="AutoGenerate"
    decryptionKey="AutoGenerate" validation="SHA1" />
    <compilation debug="true">
    <authentication mode="Forms">
        <forms loginUrl="~/Login.aspx" timeout="2880"/>
    </authentication>
...
Run Code Online (Sandbox Code Playgroud)

我的方法有问题吗?为什么到期如此之快?

编辑

Global.asax代码:

protected void Application_AuthenticateRequest(object sender, EventArgs e) …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net authentication forms-authentication

10
推荐指数
1
解决办法
2472
查看次数

禁用grails可搜索插件默认搜索页面?

我正在尝试禁用Searchable插件默认搜索页面(http:// localhost/searchable /),但还没有找到办法.任何人都知道如何做到这一点,最好是以合法的方式,但必要时采取欺骗手段?

grails searchable

5
推荐指数
1
解决办法
1012
查看次数

HTML5本地存储和Chrome

我想建立一个离线应用程序.我想知道如何在Google Chrome中清除缓存.如果用户删除了他的cookie,他的离线内容也会消失吗?

html5 google-chrome

5
推荐指数
1
解决办法
2万
查看次数

为什么在python中用字符串声明unicode?

我还在学习python,我有一个疑问:

在python 2.6.x中,我通常在文件头中声明编码,如下所示(如PEP 0263)

# -*- coding: utf-8 -*-
Run Code Online (Sandbox Code Playgroud)

在那之后,我的字符串像往常一样写:

a = "A normal string without declared Unicode"
Run Code Online (Sandbox Code Playgroud)

但每次我看到python项目代码时,都不会在标题处声明编码.相反,它在每个字符串声明如下:

a = u"A string with declared Unicode"
Run Code Online (Sandbox Code Playgroud)

有什么不同?这是为了什么目的?我知道Python 2.6.x默认设置ASCII编码,但它可以被头声明覆盖,那么每个字符串声明的重点是什么?

附录:似乎我已将文件编码与字符串编码混合在一起.谢谢你解释:)

python encoding utf-8

120
推荐指数
4
解决办法
15万
查看次数