Tag: 边界

如何在Swing中的组件边框外添加边距?

我使用了多个绘有边框的组件。 有没有简单的方法为组件添加边距,以便边框不会彼此如此接近?

绑定此程序以确定不包含零的倒数整数之和

设A表示正整数的集合,其十进制表示不包含数字0.A中元素的倒数之和已知为23.10345。 防爆。 1,2,3,4,5,6,7,8,9,11-19,21-29,31-39,41-49,51-59,61-69,71-79,81-89, 91-99,111-119,…… 然后取每个数的倒数,并总计。 如何通过数字validation? 编写一个计算机程序来validation这个号码。 这是我到目前为止所写的内容,我需要帮助解决这个问题,因为这需要很长时间才能完成: Java中的代码 import java.util.*; public class recip { public static void main(String[] args) { int current = 0; double total = 0; while(total < 23.10245) { if(Integer.toString(current).contains("0")) { current++; } else { total = total + (1/(double)current); current++; } System.out.println("Total: " + total); } } }

数组索引超出界限 – Java

我已经开始研究我的第一个Java程序,这是一个简单的计算器,但是我得到一个错误声称我的数组已经超出界限。 我试图调试它以查看其中的原因和原因,以及遵循纸上的代码,这两个代码都显示了我期望和希望的结果。 因此,我看不出问题究竟在哪里。 代码不完整。 根据调试器,错误发生在这一行: answer = outputNum.get(operationIndex) * outputNum.get(operationIndex+1); 这是我目前拥有的代码的主要部分: private class ButtonHandler implements ActionListener { /* * “outputNum” stores the numbers entered in order. * “orderOfOperations” stores all numbers in order after multiplication and division has been taken care of. * “operationList” stores the mathematical operations entered in order. * “currentNum” stores the […]

Java Regex Word Boundaries

嗨,我有以下代码,这是为了找到单词“是”,但不是当它在另一个字符串中,所以单词“this”不应返回匹配,所以我使用\ b。 但是下面的代码没有找到匹配,我无法弄清楚为什么? public static void main(String[] args) { String a = “This island is beautiful.”; Pattern p = Pattern.compile(“\bis\b”); Matcher m = p.matcher(a); while(m.find()){ System.out.println(a.substring(m.start(), m.end())); } }

边界椭圆

我已经获得了图形模块的分配,其中一部分是计算一组任意形状的最小边界椭圆。 椭圆不必是轴对齐的。 这是在使用AWT形状的java(euch)中工作,因此我可以使用所有工具形状来检查对象的包含/交集。