jframe

Lag spike when moving player

时光毁灭记忆、已成空白 提交于 2019-12-19 10:59:10
问题 The player is a panel, and it is getting removed, its position changed, and then re-added to another panel (which is what contains this method) which is drawn to the main frame. There are also a lot of other small panels containing a grass sprite being drawn to the primary panel as terrain tiles. I think the problem is that when I call revalidate() , it revalidates all those little panels as well. How can I solve this? EDIT: I should mention that I am using RelativeLayout to position the

Adding images on Java JFrame - Netbeans

别等时光非礼了梦想. 提交于 2019-12-19 10:52:07
问题 I'm using NetBeans 7.1 to code in Java. I have already created a JFrame filled with some labels, textbox and buttons . How can I do to import some image (JPG,PNG,etc...) from my PC into the same JFrame ? On an specific location of the frame. 回答1: Open the form in NetBeans form editor. Add a JLabel from the pallete to the form Select the label you just added and click the "..." button next to the icon property Fill out the properties. It's normally best that the images reside within the

Adding images on Java JFrame - Netbeans

老子叫甜甜 提交于 2019-12-19 10:52:00
问题 I'm using NetBeans 7.1 to code in Java. I have already created a JFrame filled with some labels, textbox and buttons . How can I do to import some image (JPG,PNG,etc...) from my PC into the same JFrame ? On an specific location of the frame. 回答1: Open the form in NetBeans form editor. Add a JLabel from the pallete to the form Select the label you just added and click the "..." button next to the icon property Fill out the properties. It's normally best that the images reside within the

One JFrame opening another

☆樱花仙子☆ 提交于 2019-12-19 09:48:12
问题 I have a JFrame and JPanel full of Jsomethings with an actionlistener. When the user clicks an object I want to open another JFrame. Here is what I did: public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == rejectionbutton){ RejectApp ra = new RejectApp(); ra.main(null); } } (RejectApp calls a new JFrame.) So another JFrame opens on the screen with more options. It works OK (so far), but I want to know is this standard? I mean calling the main method like

JPanel custom drawing using Graphics

*爱你&永不变心* 提交于 2019-12-19 07:32:31
问题 I have a custom JPanel and sometimes throughout my program, I need to call a method which paints the screen black, that's it. public void clearScreen() { Graphics g = getGraphics(); g.setColor(Color.black); g.fillRect(0,0,getWidth(),getHeight()); } When I launch the program, I call this method. However, I find that sometimes it works, and sometimes it doesn't. It's very odd. I also found out that when it doesn't work, the graphics object is NOT null, and the width and height are also

Java - Show a minimized JFrame window

流过昼夜 提交于 2019-12-19 07:24:35
问题 If a JFrame window is minimized, is there any way to bring it back to focus? I am trying to get it to click a certain point, then restore it. while (isRunning) { start = System.currentTimeMillis(); frame.setState(Frame.ICONIFIED); robot.mouseMove(clickX, clickY); robot.mousePress(InputEvent.BUTTON1_MASK); frame.setState(Frame.NORMAL); Thread.sleep(clickMs - (System.currentTimeMillis() - start)); } 回答1: If you want to bring it back from being iconified , you can just set its state to normal :

Java - Show a minimized JFrame window

試著忘記壹切 提交于 2019-12-19 07:24:20
问题 If a JFrame window is minimized, is there any way to bring it back to focus? I am trying to get it to click a certain point, then restore it. while (isRunning) { start = System.currentTimeMillis(); frame.setState(Frame.ICONIFIED); robot.mouseMove(clickX, clickY); robot.mousePress(InputEvent.BUTTON1_MASK); frame.setState(Frame.NORMAL); Thread.sleep(clickMs - (System.currentTimeMillis() - start)); } 回答1: If you want to bring it back from being iconified , you can just set its state to normal :

Is there a way to have the Nimbus Look&Feel render its own windows decorations for a top level JFrame?

£可爱£侵袭症+ 提交于 2019-12-19 04:20:15
问题 Is there a way to have the Nimbus Look&Feel render its own windows decorations for a top level JFrame ? I've been digging through the Internet, and I'm starting to suspect it might not be possible at all. Has anyone actually succeeded with (and cared about) that? Nimbus decorations are nice and neat for internal frames , but apparently there is no way to have the same effect on JFrame s and JDialog s. I tried nimbusx (Nimbus Extensions), a library that subclasses JFrame and JDialog and

How to replace JPanel with another JPanel

雨燕双飞 提交于 2019-12-19 03:07:19
问题 I want to replace a Jpanel with another one in a JFrame I already search and try my code but nothing's happen this is my code : public class Frame extends JFrame { private Container contain; private JPanel reChange,reChange2; private JButton reChangeButton; public Frame() { super("Change a panel"); setSize(350, 350); setLayout(null); setLocationRelativeTo(null); setResizable(false); reChange = new JPanel(null); reChange.setBackground(Color.red); reChange.setSize(240, 225); reChange.setBounds

Find the location/Position of JFrame in the window

我怕爱的太早我们不能终老 提交于 2019-12-18 20:12:08
问题 I am trying to find the Starting location/position of the JFrame in order to map the mouse cursor from the JFrame window to desktop. Is there anyway to find the X,Y position of JFrame ? 回答1: You can use getLocation() or getLocationOnScreen() method of JFrame which are inherited from java.awt.Component. 回答2: you have to implement the MouseListener Interface and call the override methods public void mouseEntered(MouseEvent me) and use MouseEvent.getX(); MouseEvent.getXOnScreen(); 回答3: Jframe