jframe

Java/Swing: reference a component from another class

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 02:02:02
问题 I have a Swing-GUI (built with Netbeans GUI-Builder), there is an label which I move around using the arrow-keys. Pressing the space-key another class is called. How can I access the label from this class and e.g. get the position? Thanks in advance for help! Example-Code of the second class: public class Xy extends Thread { private Window s; // this is the jFrame-form public Xy(Window s) { this.s = s; s.setBackground(Color.yellow); // works } public void run() { // here i want to use the

JScrollPane scrollbars not scrollable

◇◆丶佛笑我妖孽 提交于 2019-12-08 01:34:14
问题 I have a class that draw some very simple graphics like lines, circles and rectangles. The lines are dynamically expandable and sometimes when they expand beyond the resolution, it is impossible to see without a scroll bar. Therefore, I've added JScrollPane to my JFrame but unfortunately, the scroll bar is not scrollable despite calling the Layout Manager already. Here's what I have: - A class that draws components (lines, rectangles, circles) - A class that sets up the JFrame/JScrollPane

Make a Java application invisible to a user

怎甘沉沦 提交于 2019-12-07 21:30:55
问题 I'm trying to figure out a way to make a Java application invisible to the user. Basically just trying to remove this <- Image How can this be done? public class TransparentWindow extends JFrame { public TransparentWindow() { initComponents(); } @SuppressWarnings("unchecked") private void initComponents() { setExtendedState(Frame.MAXIMIZED_BOTH); setResizable(false); setUndecorated(true); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); setAlwaysOnTop(true); System.setProperty(

How do i draw a triangle in java?

烂漫一生 提交于 2019-12-07 19:46:44
问题 Ok so first of all i know how to draw a rectangle and circles and ect with g.drawRect or g.drawOval but there is no g.drawtriangle so can you guys tell me if there is a way to draw a triangle with out me having to draw it out each side of the triangle. 回答1: You may use Graphics.drawPolygon(int[], int[], int) where the first int[] is the set of x values, the second int[] is the set of y values, and the int is the length of the array. (In a triangle's case, the int is going to be 3) Example:

Can't Edit JFrame Form after NetBeansUpdate

左心房为你撑大大i 提交于 2019-12-07 14:50:09
问题 Lately, I've been working on a project in NetBeans using the GUI editor that's built in. Before I noticed that it generated an XML ".form" file that didn't appear in the Project Explorer Pane which makes sense. Earlier I was working on the form in the "Design" tab when it notified me about 15 updates. I just updated without reading anything which was probably a bad idea but when I restarted the IDE, it showed my GUI ".class" file and ".form" file separately in the Project Explorer and I

Java Swing JFrame Background is not showing

纵然是瞬间 提交于 2019-12-07 13:23:53
问题 I don't know why the background color is not showing on my Jframe. Below is the code that I tried. When I call AnimatedDialogBox animatedDialogBox = new AnimatedDialogBox("Saving TransSet form", dataSheetTable); Its not showing the exact color that I needed. It shows without any background color. The AnimatedDialogBox class is per below : import java.awt.Color; import java.awt.Dimension; import java.awt.Point; import java.awt.Toolkit; import java.beans.PropertyChangeEvent; import java.beans

how to pause program until a button press?

你说的曾经没有我的故事 提交于 2019-12-07 10:36:23
问题 i use from a class that extended from jframe and it has a button(i use from it in my program) i want when run jframe in my program the whole of my program pause until i press the button. how can i do it in c++ getch() do this. i want a function like that. 回答1: Pausing Execution with Sleep, although I doubt that is the mechanism that you'll want to use. So, as others have suggested, I believe you'll need to implement wait-notify logic. Here's an extremely contrived example: import java.awt

How to detect if one swing window is above another one

蹲街弑〆低调 提交于 2019-12-07 09:01:26
问题 I have several unrelated JFrames opened in my app. And on app exit I should remember the preferences of all of them to restore them the same view they was before exit. The problem is when these frames are located one above another, they should be restored in the same order. Another way the smaller frames would not be visible under bigger ones. QUESTION: How can I detect the deep location each of frames in this case? UPD: I detect this case by comparing the frames' location/size pairs , but I

How to make “Enter” Key Behave like Submit on a JFrame

心已入冬 提交于 2019-12-07 08:46:00
问题 I'm Building a Client/Server application. and I want to to make it easy for the user at the Authentication Frame. I want to know how to make enter -key submits the login and password to the Database (Fires the Action) ? 回答1: One convenient approach relies on setDefaultButton(), shown in this example and mentioned in How to Use Key Bindings. JFrame f = new JFrame("Example"); Action accept = new AbstractAction("Accept") { @Override public void actionPerformed(ActionEvent e) { // handle accept }

JScrollPane doesn't work for my JPanel

二次信任 提交于 2019-12-07 07:35:17
问题 first of all I must say that I have checked these questions and didn't find my answer : 1 , 2 , 3 , 4 , 5 , 6 , 7 and many other questions like so also I have checked these tutorials and examples: 1 , 9 , 10 , 11 and many other sites. but I couldn't fix my problem. and this is the simple kind of my code: public class Question extends JFrame { public Question() { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); setLayout(new BorderLayout()); setSize(d.width, d.height); setResizable