jframe

Display java JPanel in a JFrame

笑着哭i 提交于 2019-12-12 17:23:13
问题 I'm having problems getting my JPanel to display properly. I want to use different extended JPanels to display what I want the user to do with this program (which is ultimately to display photographs). Below is the code for the only two classes that exist at this point. Unfortunately, I'm having problems just getting this to work right out of the gate with the first panel which was to present the user with the ability to select different graphic images. What's happening is, I can't get my

Java - Screen Size on a Mac

风格不统一 提交于 2019-12-12 16:07:53
问题 I have a Java application, and in order to find the size of the screen to use, I do the following, for example: Toolkit.getDefaultToolkit().getScreenSize().width; Toolkit.getDefaultToolkit().getScreenSize().height; In my application, I am painting some items on the screen. And to determine the position, I use these values for width and height (because I want a particular item at the very bottom). But, I'm finding that it is going off the screen, even though it's position doesn't exceed what

Why are the contents of my JFrame not displaying correctly?

痞子三分冷 提交于 2019-12-12 15:48:02
问题 For the sake of less code, I am taking out code that is unrelevant to the problem, such as addActionListener(); etc. My main class is public class TF2_Account_Chief I have my main Jframe f; and its contents: private static JFrame f = new JFrame("TF2 Account C.H.I.E.F."); private JLabel runnableTogetherLabel = new JLabel("How many idlers would you like to run at a time?"); private static JTextField runnableTogetherInput = new JTextField(); private JButton runButton = new JButton("Run!");

My JFrame Flickers

筅森魡賤 提交于 2019-12-12 15:23:26
问题 I'm trying to make a simple java game -- driving a car through a track. I am conditioned by my teacher to use rectangles and stuff like that . My problem is when I use the method repaint() that my frame flickers. I have tried to put the repaint method just when the car changes direction, but it doesn't do any good. Any suggestions? import java.awt.Color; import java.awt.Graphics; import java.awt.Image; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.event.KeyEvent; import

Is there a way to remove frame decoration without re-opening it? [duplicate]

北慕城南 提交于 2019-12-12 15:21:37
问题 This question already has answers here : How to call setUndecorated() after a frame is made visible? (7 answers) Closed 4 years ago . I am making a simple bible reader, and I want to have a fullscreen option. By default, the frame is maximized, but the frame is there. I have a method, setFullScreen , that removes decoration. However, it does not seem to update after being initialized. Is there a way around this? setFullScreen method: public void setFullScreen() { mainFrame.setUndecorated(true

JFrame intercept exit on close to save data

自作多情 提交于 2019-12-12 13:27:13
问题 I created a window and want to intercept the exit with the method windowStateChanged to save the data before the application closes. However, it doesn't appear to be saving the data before it closes. How can I correct this? see code below: public class InventoryMainFrame extends JFrame implements WindowStateListener{ //set up the main window - instantiate the application private InventoryInterface inventoryInterface; //panel that contains menu choices and buttons public InventoryMainFrame(){

Changing the Panels of a JFrame “disable” the inputMap of the new Panel inserted

给你一囗甜甜゛ 提交于 2019-12-12 12:15:45
问题 Description of the problem: I have a JFrame, inside this JFrame there is a JPanel with a button, when I press the button an action listener change the current JPanel with a new JPanel, which contains other two JPanels, those two have an inputMap that when the user press the key "up" make something on both of them. The problem is: when I change the JPanel with the new one the "up" key won't do anything. Here is the code: is a SSCCE, so you just have to copy and paste to see what it does. This

How To Play MP4 Video In Java Swing App

孤街浪徒 提交于 2019-12-12 12:09:00
问题 Does anyone know any way I can play an .mp4 video file in a JPanel? I have tried JMF with .avi file but found no success and now I'm baffled and frustrated at how such a simple task of playing a video file is becoming so tedious. Anyone out there please shed some light on what path I could take and I would greatly appreciate it. I've heard of VLCJ but the issue is I can't guarantee that every machine running this app will have VLC player installed. Is there a way I can bundle VLC player in

change JPanel after clicking on a button

喜你入骨 提交于 2019-12-12 09:27:17
问题 I'm building simple GUI for my app. I have couple of JPanels. I want to display them depending on action that was performed by clicking on a JButton. How can I disable one JPanel and enable another one ? Couple of details. I have a class with JFrame where I'm building starting gui. Where I have buttons and some text. Clicking on one of the buttons should change the view in this JFrame my button definition JButton btnStart = new JButton("Start"); btnStart.addActionListener(new ActionListener()

Implementing auto complete in Java - am I doing it right? [duplicate]

≯℡__Kan透↙ 提交于 2019-12-12 08:25:53
问题 This question already has answers here : Create a autocompleting textbox in Java with a dropdown list (7 answers) Closed 6 years ago . Algorithm Start Input a city name - partial or complete If the user hits enter , take the text from JTextField Begin brute force search. If the matches are found, put them in a Vector and put it in a JList If no match is found, add a String "No Match Found" in Vector Display JWindow to user containing the results Stop Code: package test; import javax.swing.*;