小编kma*_*zek的帖子

使用Graphics2D绘制图像

我正在尝试使用java的Graphics2D在屏幕上绘制图像.这是我正在使用的代码.我希望看到一个图像在屏幕上稳定移动.目前我可以看到图像,但除非我调整窗口大小,否则它不会移动,在这种情况下它会移动.我已经勾勒出下面的课程了.

 public class Tester extends JFrame {

    private static final long serialVersionUID = -3179467003801103750L;
    private Component myComponent;
    public static final int ONE_SECOND = 1000;
    public static final int FRAMES_PER_SECOND = 20;

    private Timer myTimer;

    public Tester (Component component, String title) {
        super(title);
        myComponent = component;
    }

    public void start () {

        myTimer = new Timer(ONE_SECOND / FRAMES_PER_SECOND, new ActionListener() {
            @Override
            public void actionPerformed (ActionEvent e) {
                repaint();
            }
        });
        myTimer.start();
    }

    @Override
    public void paint (Graphics pen) {
        if …
Run Code Online (Sandbox Code Playgroud)

java graphics swing graphics2d

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

可以在一个对象上多次调用Dispose()会导致崩溃吗?

我正在调查我的应用程序中的零星崩溃,但仍然不确定是什么导致它.当我想要关闭包含VB 6.0或VC 6.0 Text控件的MDI表单时,有时会发生这种情况 - 它的C#包装为Interop.在查看代码时,我注意到我有一些这样的代码:

 private void Dispose(bool disposing)
    {
        if (!this.disposed)
        {
            if (disposing) //Disposing of everything: managed and unmanaged resources.
            {
                moTextEditor.Dispose();  --here
                moTextEditor.Dispose();  --here
            }

            // Deal with our own & whatever other unmanaged resources (this used to be done in the finalizer, above)
            SetLockedFields(false);

            disposed = true;
        }
    }
Run Code Online (Sandbox Code Playgroud)

所以注意到moTextEditor.Dispose(); 线重复两次?你怎么看?这可能是问题吗?

c# crash winforms

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

FontSize.PIXELS c#等价物

我有以下J#代码

bigFont = new Font("Arial", bigFontSize, FontSize.PIXELS);
Run Code Online (Sandbox Code Playgroud)

我如何将上面的行转换为c#FontSize.PIXELS等价物.

谢谢

.net c# j# winforms

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

在linq查询中区分大小写

这段代码使用Authentication person进行登录,我的问题是密码,例如if

pass = AAaa我们在系统中输入aaaa登录,如何处理搜索中的区分大小写?

Inspector inspector = context.Inspectors.Where(i => i.InspectorUserName == userName

                && i.InspectorPssWord == passWord).FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)

谢谢

c# linq

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

删除了Switch语句以解决错误并且错误仍然存​​在.

这是我的问题.我从此方法中删除了switch语句,因为我必须更改它以适应多个变量,而switch语句只允许char常量.在没有java版本7的情况下,无法将字符串用于变量.所以我所做的就是改为通常的if/else语句.但是在尝试运行程序时,我仍然在switch语句中收到错误,如下所示:

有任何想法吗?如果我希望包含测试人员的代码,我可以问一下.

java.lang.Error:未解决的编译问题:无法为源级别低于1.7的值打开String类型的值.只允许使用可转换的int值或枚举变量

在Project2.PostfixEvaluator.calculate(PostfixEvaluator.java:124)位于Project2.PostfixEvaluator.eval(PostfixEvaluator.java:71)的Project2.ExpressionEvaluator.evaluate(ExpressionEvaluator.java:29),位于Project2.ExpressionEvaluatorTester.main(ExpressionEvaluatorTester.java: 32)

public Token calculate(Token opr, Token opd1, Token opd2)
    {
        // Get the first String from opr, it is the operator: +, -, ...
        String oper = opr.getBody();

        System.out.println(opr);

        //Get the two operands by converting from String to int
        int op1 = Integer.parseInt(opd1.getBody());
        int op2 = Integer.parseInt(opd2.getBody());

        //Default return value, in case an error occurs
        int res = 0;

        /**
         * Alterations begin here
         * Performs operation and sets value for res
         */

           if(oper.equals("+")) 
           {
               res …
Run Code Online (Sandbox Code Playgroud)

java compiler-errors switch-statement

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

给出一个大的网址列表,有什么方法可以检查哪些是活动/非活动的?

假设我给出了这个网址列表:

website.com/thispage

website.com/thatpage

website.com/thispageagain

website.com/thatpageagain

website.com/morepages

...可能超过1k urls.

什么是最好/最简单的方法来循环查看此列​​表并检查页面是否已启动?

python

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