如何在Swing Java中设置Tab顺序?

我想知道如何在Swing界面中调整Tab顺序。 我找到了一个例子,它表明这种方法应该可以解决这个问题,但它似乎已被弃用而且无法正常工作。 getCombox(“cmbFrom”).setNextFocusableComponent(getCombox(“cmbTo”)); 注意: – 下面的方法返回带有Argument名称的Combox对象。 如果有人知道如何使用Netbeans IDE,它会很棒。 我在Eclipse WindowBuilder中找到了一种方法,但在Netbeans IDE中没有。 谢谢。 getCombox(String s)

Java Runtime.maxMemory不正确?

我运行了以下方法Runtime.getRuntime()。maxMemory()并给出了85196800。 但是,然后我从命令行运行顶部,它显示 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 8672 root 20 0 1284m 156m 4296 S 0.3 60.9 0:33.35 java 这不显示使用156M的ram吗? 有什么想法发生了什么?

是不支持meta http-equiv值缓存控件?

我在这个页面上有这个代码: 当我转到其他页面并点击浏览器的按钮(返回到此代码编写的页面)时,它仍然具有页面的缓存状态。 选项是,添加PhaseListener,但他们告诉我添加PhaseListener是一个额外的代码来维护。 问题是: 1.是元标记属性http-equiv值在所有浏览器的html中仍然支持cache-control? 因为当我在w3school登记时,属性http-equiv没有值缓存控制,编译指示和过期。 2.如果我添加了phaseListener,那么在每个页面中添加元标记会有什么好处。 谢谢你

在Android上获取所有文件夹google drive api

我使用新的谷歌驱动器API,我无法从我的谷歌驱动器获取所有文件夹,我只获得我用谷歌驱动器API创建的文件夹…任何人都知道为什么会这样? 这是我的代码: @Override protected void onResume() { super.onResume(); if (mGoogleApiClient == null) { // Create the API client and bind it to an instance variable. // We use this instance as the callback for connection and connection // failures. // Since no account name is passed, the user is prompted to choose. mGoogleApiClient = new […]

如何在java中的ArrayList上添加监听器

我想在java中创建自己的ArrayList实现,可以在列表更改时进行侦听,并在发生这种情况时执行操作。 根据我的阅读,我明白我不能扩展ArrayList然后添加监听器。 我想在类中使用MyList作为带有public修饰符的变量,因此用户可以直接更改它并在更改时执行操作。 class MyList extends ArrayList…. { … } class UseOfMyList { public MyList places = new MyList(); places.add(“Buenos Aires”); //and to be able to do that List cities = new ArrayList(); cities.add(“Belmopan”); places = cities; 那么如何创建以及何时添加,删除或传递另一个列表到MyList要执行的操作?

使用非Comparable类创建TreeSet:为什么是运行时exception,而不是编译时错误?

如果我创建一个没有实现Comparable的任意类,并尝试将其用作树集,则在插入对象时会在运行时抛出exception: public class Foo { } public TreeSet fooSet = new TreeSet(); fooSet.add(new Foo()); // Throws a ClassCastException exception here: Foo is not comparable 我不是Java专家,但是有些东西似乎是以我没想到的方式动态地输入(ala Python)。 TreeSet的实现是否无法指定其generics类型参数必须实现Comparable以便可以在编译时捕获它? 非generics函数可以将接口作为参数; 仿制药是不可能的?

如何在OS X中将java FileDialog接受目录作为其FileType?

当我的应用程序在Mac上运行时,我试图从使用JFileChooser切换到FileDialog,以便它将使用OS X文件选择器。 到目前为止,我有以下代码: FileDialog fd = new FileDialog(this); fd.setDirectory(_projectsBaseDir.getPath()); fd.setLocation(50,50); fd.setFile(?); fd.setVisible(true); File selectedFile = new File(fd.getFile()); 我会为这个问题投入什么? 所以我的文件选择器将允许任何目录作为文件选择器的输入(后面的方法已经检查以确保该目录是我想让FileDialog接受任何目录的正确类型的目录)。

Java Keybindings

我需要绑定所有箭头键来执行相同的function,但每次都按下哪个键。 目前我只有在通过以下方式按下右箭头键时才有 DoneImg.getInputMap(JLabel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), “UpArrow”); Action MvRight = new AbstractAction() { public void actionPerformed(ActionEvent e) { //Do whatever here } }; DoneImg.getActionMap().put(“RightArrow”, MvRight); 但我需要类似的东西 DoneImg.getInputMap(JLabel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), “RightArrow”); DoneImg.getInputMap(JLabel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), “LeftArrow”); DoneImg.getInputMap(JLabel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), “DownArrow”); DoneImg.getInputMap(JLabel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), “UpArrow”); Action MvAll = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (e.keypressed == “LeftArrow”) {System.out.println(“The left arrow was […]

jvm.cfg文件与Java相关的目的是什么?

它有一些奇怪的关键字。 请解释该文件的一般用途。

在文件系统上直接使用PEM编码CA证书进行HTTPS请求?

这类似于将PEM导入Java密钥库 。 但问题的答案使用OpenSSL进行转换和工具,将它们导入文件系统的密钥存储区。 我正在尝试使用格式良好的X509证书作为信任锚: static String CA_FILE = “ca-rsa-cert.pem”; public static void main(String[] args) throws Exception { KeyStore ks = KeyStore.getInstance(“JKS”); ks.load(new FileInputStream(CA_FILE), null); TrustManagerFactory tmf = TrustManagerFactory .getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ks); SSLContext context = SSLContext.getInstance(“TLS”); context.init(null, tmf.getTrustManagers(), null); // Redirected through hosts file URL url = new URL(“https://example.com:8443”); HttpsURLConnection connection = (HttpsURLConnection) url .openConnection(); connection.setSSLSocketFactory(context.getSocketFactory()); … […]