jpanel

Killing all processes, force everything to stop

十年热恋 提交于 2019-12-13 04:25:14
问题 I have a game that runs off of JPanel which has on it many other things which have their own independent timers and such. It seems that when I try to remove the panel from my frame to replace it with another JPanel it refuses to actually end all of its own processes. So even if I am able to remove it from the screen of the panel by removing it and setting it null , its processes are still going off in the background, IE the music and the stuff flying around. What i need to know is some

Top layer in JLayeredPane not displaying

◇◆丶佛笑我妖孽 提交于 2019-12-13 04:20:34
问题 I'm trying to create a panel that uses a JLayeredPane to have a panel centered above another, larger panel. I can't seem to get the smaller panel to display though. Any ideas as to what I'm doing wrong? import java.awt.Dimension; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLayeredPane; import javax.swing.JPanel; public class MainPanel extends JPanel { private JLayeredPane pane; private AllPlayersPanel players; //Larger panel,

How can I redirect my jfreecharts into the tabs?

流过昼夜 提交于 2019-12-13 04:19:23
问题 I have 6 tabs that are named for different zones (A,B,C,S,SH,W) and each show their own data from the csv file. Inside the csv file I have a columns of # milliseconds that I convert to Hour and minutes and the other column is the letter of the Zone (same as tabs). I can display the data on the tab but it just shows each of the zones data in one tab. I am trying to show each of the zone's data in each of their own tabs. How should I approach this? I already looked at this topic but it didn't

JPanels not being drawn in JFrame

浪子不回头ぞ 提交于 2019-12-13 04:18:42
问题 I'm working on a vertical scrolling game, and I'm using a thread to generate new enemies every 2 seconds. Each enemy is an image in a JPanel. For some reason, The generated enemies are not showing up in the JFrame, but they are present. When the player collides with one of the enemies, all the enemies show up. This is the main class: package asteroidblaster; import javax.swing.*; import javax.swing.Timer; import java.awt.event.*; import java.awt.*; public class Main extends JFrame { /** * */

Change jLabel Visibility

别等时光非礼了梦想. 提交于 2019-12-13 03:47:53
问题 I am new to Netbeans and Java and am having an issue with jLabels that are on jPanels. I have a jTabbedPane with a jPanel in it. I have a jLabel on the jPanel. I would like to set the visibility of the jLabel to false, but it does not seem to work. The label is still visible when I run the program. I do not understand why. Label label = new Label("jLabel1"); label.setVisible(false); 回答1: You can set it inside initComponents() ; package my.tt; public class NewJFrame extends javax.swing.JFrame

how to make jpanel in jframe visible

为君一笑 提交于 2019-12-13 03:46:44
问题 I try to write a menue for a little game in Java. I thought it would be a good idea to have a Window class (extending JFrame) and then put a JPanel in it for the different Screens (Menue, Game, GameOver etc) If I put the buttons and stuff directly in the JFrame everything is shwown correct, but when I try to put a JPanel into the JFrame it doesn't work. Here is the code: public class Window extends JFrame{ private final int WIDTH = 800; private final int HEIGTH = 600; private final int

sliding window under a JPanel

狂风中的少年 提交于 2019-12-13 03:39:57
问题 I have a JPanel and I want it so that whenever a user clicks on it, a sliding window appears just below the panel and giving more information to what is already in the JPanel. How can I do this? 回答1: To put something on something, you can use a JLayeredPane or the zorder thing. 回答2: Try this http://java-sl.com/tip_slider.html 回答3: The requirements of your question are terrible so we can't give much detail. If you want to to animation then use a Swing Timer. Each time the timer fires you

Drawing Shapes with lines on a transparent Graphics2D to get a png image

不羁的心 提交于 2019-12-13 03:38:35
问题 So my goal is to have a window that opens where you can draw some lines on a white background by just clicking. The problem is that when it try to save it always comes back as a png, but it comes as a square image. If I draw a triangle with my lines I get a triangle inside a white square but I want the triangle only. I would really appreciate any help I tried every solution I came accross on stackoverflow and I tried to understand Graphics2D in depth but sadly failed public class Draw{ public

Switching JPanels moves content diagonally

不打扰是莪最后的温柔 提交于 2019-12-13 03:36:29
问题 I have btnShowLibrary, which shows the books kept in the library. And then I have a button btnReturn that recreates previous JPanel with the btnShowLibrary among them. Initializing contentPane: setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new MigLayout("", "[124px,grow,fill][124px,grow,fill][124px,grow,fill]", "[30px,grow,fill]

how to add component in box layout on north of other and make them all anchor on south?

元气小坏坏 提交于 2019-12-13 02:57:50
问题 I try to make a very mini game. I have one JPanel , it uses a BoxLayout.Y_AXIS that contains three JLabel (name of JLabels = 1,2,3) I need a component inside that panel to anchor on South (so I use glue) The view result will be like this: 1 2 3 Then I have a JButton . If the user clicks the button, that JPanel adds a new JLabel (name of JLabel = neww) Here is the view result: 1 2 3 neww but I need something like this: neww 1 2 3 how should I do? Is it possible to handle it with BoxLayout ?