swing

Java - How can i select all rows in JTable using Command+A shortcut in Mac?

给你一囗甜甜゛ 提交于 2021-02-10 05:04:21
问题 I have many tables in my Java application. When i click "Ctrl + A" in Mac OS X, it selects all rows inside the current table. I wonder if i can change the default shortcut to use "Command + A" instead to select all the rows in the table ? I am trying to do this inside the EventQueue class to be applied automatically on all the tables in my application. 回答1: Swing uses Key Bindings to map KeyStrokes to Actions . So you can add another binding to map "Command A" to the existing "Control A"

Why does a JButton under a JPanel still react?

让人想犯罪 __ 提交于 2021-02-10 03:27:48
问题 I looked around for my problem, and i couldn't find an answer, so here I go: I have a JLayeredPane, and in there there are 2 JPanels. The deepest one ( furthest down ) has JButtons on there. The second one ( The one on top ) has a partially transparent background color ( although i don't think this should influence it ). Now when I hover over my JButtons ( which are behind the other JPanel ), they still fire events to the MouseListener I added to them. I don't know why... Why is this the case

Why does a JButton under a JPanel still react?

£可爱£侵袭症+ 提交于 2021-02-10 03:24:15
问题 I looked around for my problem, and i couldn't find an answer, so here I go: I have a JLayeredPane, and in there there are 2 JPanels. The deepest one ( furthest down ) has JButtons on there. The second one ( The one on top ) has a partially transparent background color ( although i don't think this should influence it ). Now when I hover over my JButtons ( which are behind the other JPanel ), they still fire events to the MouseListener I added to them. I don't know why... Why is this the case

run function on JButton press

混江龙づ霸主 提交于 2021-02-09 12:21:54
问题 I'm attempting to make a program in java that uses a robot to press a specific key every few seconds. It has a GUI with a start and stop button and a label which tells which state its in. I've got everything working so far except that when I click "start" it runs the loop for my robot function (which is infinite) it doesn't enable the stop button like I thought it would. I know its something stupid with where the infinite loop is placed but I'm not sure how to make it work correctly. I don't

run function on JButton press

倾然丶 夕夏残阳落幕 提交于 2021-02-09 12:21:51
问题 I'm attempting to make a program in java that uses a robot to press a specific key every few seconds. It has a GUI with a start and stop button and a label which tells which state its in. I've got everything working so far except that when I click "start" it runs the loop for my robot function (which is infinite) it doesn't enable the stop button like I thought it would. I know its something stupid with where the infinite loop is placed but I'm not sure how to make it work correctly. I don't

201771010113 李婷华 《面向对象程序设计(Java)》第八周总结

假装没事ソ 提交于 2021-02-09 09:02:29
一.理论知识部分 1.Java 为了克服单继承的缺点, Java 使用了接口, 一个类可以实现一个或多个接口。 2. 在 Java 程序设计语言中,接口不是类,而是对类 的一组需求描述,由常量和一组抽象方法组成。 接口中不包括变量和具体实现的方法。 3. 只要类实现了接口,则该类要遵从接口描述的统 一格式进行定义,并且可以在任何需要该接口的 地方使用这个类的对象。 4. 接口声明方式: public interface 接口名。 接口体中包含常量定义和方法定义,接口中只进 行方法的声明,不提供方法的实现。 类似建立类的继承关系,接口也可以扩展。 5. 接口的 扩展方法: public interface 接口 1 extends 接口 2 6. ( 1 )通常接口的名字以 able 或 ible 结尾; ( 2 )可以使用 extends 来继承接口的常量和抽象方 法,扩展形成新的接口; ( 3 )接口中的所有常量必须是 public static final ,方法必须是 public abstract ,这是 系统默认的,不管你在定义接口时,写不写 修饰符都是一样的。 7.接口的实现:在类声明时用 implements 关键字声明使用一个或 多个接口。 一个类使用了某个接口,那么这个类必须实现该 接口的所有方法,即为这些方法提供方法体。 一个类可以实现多个接口

“java.lang.UnsatisfiedLinkError: no awt in java.library.path” in running JWS Swing app

一曲冷凌霜 提交于 2021-02-08 17:24:56
问题 We are sometimes getting this strange error from clients (automatically, no user report was filled until now), and none of us can make sense of it. A user starts our Swing Java-Web-Start "fat client" on a Win7 machine, eventually use some action that should produce a PDF document (using an ancient, modified Apache FOP version), and end up getting this error. So far, it's not reproducible on our side. Google did not help on this one either. The big question is, how can awt dll be missing, when

Get audio to play in JAR File

不想你离开。 提交于 2021-02-08 12:12:56
问题 I know this question has been asked many times and I've looked at many in hopes to figure out my problems, but it didn't really help much. I was given this class to use to play WAV files on my GUI and it works when retrieving local files. But it doesn't work in a JAR file. I know this is because the music class only works for retrieving local files, so I need help changing the code to retrieve music files from the JAR. Here's the SoundPlayer class: package extra; import java.io.IOException;

How to make jtable on full jframe window

扶醉桌前 提交于 2021-02-08 12:07:18
问题 i am trying to create a jtable using java swing and little bit i am able to do this but problem is this that i want to create that jtable on full jframe window how can i do this here is my code given below import javax.swing.*; import javax.swing.table.*; import java.awt.*; public class ScrollableJTable{ public static void main(String[] args) { new ScrollableJTable(); } public ScrollableJTable(){ JFrame frame = new JFrame("Creating a Scrollable JTable!"); JPanel panel = new JPanel(); String

How to make jtable on full jframe window

非 Y 不嫁゛ 提交于 2021-02-08 12:06:49
问题 i am trying to create a jtable using java swing and little bit i am able to do this but problem is this that i want to create that jtable on full jframe window how can i do this here is my code given below import javax.swing.*; import javax.swing.table.*; import java.awt.*; public class ScrollableJTable{ public static void main(String[] args) { new ScrollableJTable(); } public ScrollableJTable(){ JFrame frame = new JFrame("Creating a Scrollable JTable!"); JPanel panel = new JPanel(); String