jframe

how to set Jframe for 5 second

纵然是瞬间 提交于 2021-02-11 17:52:45
问题 I'm using netbeans 7.1.1, to create a JFrame. I want to automatically dispose the JFrame 5 seconds after calling setVisible() . How can I do this? 回答1: HINT Use Swing Timer to wait for 5 seconds before calling setVisible(false) or dispose() whichever way you want it implemented. Hidden/Disposed 回答2: Did u do your research on this? Seems straight forward. new Timer().schedule(new TimerTask() { public void run() { // this should be final jframe.dispose(); } }, 5000); 来源: https://stackoverflow

Listing objects in ArrayList in GUI and alternating between many ArrayLists

让人想犯罪 __ 提交于 2021-02-11 16:46:47
问题 I'm currently working on a personal project, in this project, the user is asked to create objects under 3 different categories, so after the object is created, there's a method that check's the category of the object and then it adds it to an ArrayList. More Details: the object is called Vehicle, there're three categories: Two wheels, three weels, three wheels. So, when you create a new Vehicle, you'd be asked to specify what kind of vehicles you're creating, say you said two wheels, a method

JAVA - JFrame not looking proper when called from action listener

旧城冷巷雨未停 提交于 2021-02-11 12:19:01
问题 I have a problem with one of my frames not looking as it should, when it is called upon the press of a button. The frame looks as if it was rendered improperly, the label text in it is shortened, however when i move the same line of code outside the action listener, it works as it should. I have a sort of main menu, with two buttons, only the Generate Menu works at the moment, it looks like this: https://i.imgur.com/k1Ne5v9.png The code for the action listener: runMenuButt.addActionListener

Can you add JButtons inside a JPanel

拟墨画扇 提交于 2021-02-11 06:16:06
问题 I'm making a Battleship game using one board. The picture below shows how the board GUI should look. My current code sets up a board without the 'menu-layer'. (see picture) I tried doing this using Swing GUI designer in Intellij and got the following form (see picture), but can't find a way to insert these buttons inside the panel. Currently, I have got the following code. package BattleshipGUI; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class BoardFrame extends

Java on Eclipse won't show the JPanel even when I add it to JFrame

安稳与你 提交于 2021-02-10 18:16:06
问题 These are the files. I have set JFrame to be visible, and have added JPanel to it, but still, the code only shows the window without anything in it. import java.util.List; import java.util.ArrayList; import java.util.Random; import javax.swing.JFrame; import javax.swing.JPanel; import java.util.Collections; public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(350, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("My Empty Window");

Multiple JFrames for Game scenario

Deadly 提交于 2021-02-10 08:12:11
问题 I'm sorry if the title is worded a bit incorrectly. I have recently started a new Game project, and have thought about the use of multiple JFrame s in Java. The reason being is my game has 2 JFrame s: 1) Main Menu ( which is a singleton) 2) Battle. Now the MainMenu JFrame will initialize the Battle JFrame on its own EDT, and then hide itself via setVisible(false) ,when the game is over setVisible(true) can be called from Battle frame on the MainMenu frame singleton. NB: The reason I did this

Multiple JFrames for Game scenario

你离开我真会死。 提交于 2021-02-10 08:11:18
问题 I'm sorry if the title is worded a bit incorrectly. I have recently started a new Game project, and have thought about the use of multiple JFrame s in Java. The reason being is my game has 2 JFrame s: 1) Main Menu ( which is a singleton) 2) Battle. Now the MainMenu JFrame will initialize the Battle JFrame on its own EDT, and then hide itself via setVisible(false) ,when the game is over setVisible(true) can be called from Battle frame on the MainMenu frame singleton. NB: The reason I did this

Multiple JFrames for Game scenario

梦想与她 提交于 2021-02-10 08:07:50
问题 I'm sorry if the title is worded a bit incorrectly. I have recently started a new Game project, and have thought about the use of multiple JFrame s in Java. The reason being is my game has 2 JFrame s: 1) Main Menu ( which is a singleton) 2) Battle. Now the MainMenu JFrame will initialize the Battle JFrame on its own EDT, and then hide itself via setVisible(false) ,when the game is over setVisible(true) can be called from Battle frame on the MainMenu frame singleton. NB: The reason I did this

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