jframe

JLabel and JLayeredPane - How to display an image over another image?

泄露秘密 提交于 2019-12-03 17:04:17
I try to create a little game in java but I'm in trouble. When I draw a map, I'm not able to display the characters without overwrite the titlesets of the squares. My goal is to be able to display many pictures on the same square (like the titleset of the grass, the character and a tree), so I have to deal with the transparency of my pictures (this is not the problem) and the layer (it is the problem). So how can I display an image on another image? How can I explain to java that I need to display this image on or under another image? This is my source code. I don't know is that can help you.

How can I change the default look and feel of Jframe? (Not theme of Netbeans)

放肆的年华 提交于 2019-12-03 16:51:44
问题 I want to change the default look and feel of all the jframe forms I'll create from here on out instead of having to manually edit every look and feel code of every jframe I create from 'Nimbus' to 'Windows'. So what I want to happen is that from when I startup Netbeans to when I create a new Jframe, the code for the look and feel of that Jframe I just created will automatically be set to "Windows" rather than "Nimbus". I want the look and feel code to look like this right after I click 'New

JAVA: Ways to fill a Frame. add(), setContentPane(), getContentPane()

半腔热情 提交于 2019-12-03 10:50:49
I found three ways to fill my JFrame frame = new JFrame("...") createContentPanel returns a JPanel and createToolBar returns a ToolBar. frame.add(this.createToolBar(), BorderLayout.PAGE_START); //this works and puts the ToolBar above and the ContentPanel under it<br> frame.add(this.createContentPanel(), BorderLayout.CENTER); frame.setContentPane(this.createContentPanel()); //this lets the JToolBar hover over the ContentPanel frame.getContentPane().add(this.createToolBar()); frame.getContentPane().add(this.createContentPanel()); //this only puts the last one into the JFrame frame.getContentPane

What is the difference between a JFrame and a JDialog?

自作多情 提交于 2019-12-03 09:11:21
问题 What is the difference between a JFrame and a JDialog ? Why can't we use setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE); for a JDialog? 回答1: JFrame is a normal window with its normal buttons (optionally) and decorations. JDialog on the other side does not have a maximize and minimize buttons and usually are created with JOptionPane static methods, and are better fit to make them modal (they block other components until they are closed). But both inherit from Window, so they share much

When you use Frame or JFrame in Java? [duplicate]

*爱你&永不变心* 提交于 2019-12-03 07:38:41
Possible Duplicate: What is the difference between swing and awt? I often see that JFrame is used a lots. But sometimes, I also see that programmer use Frame in their example. So could you tell me the advantages/disadvantages of them? Well let me break it up for you.............. Before jumping into Frame Vs JFrame, let me explain you about AWT and Swing. AWT : - It has a Platform Dependent Look and Feel . - So it uses the Native GUI components. - As AWT uses the peer components, its called as Heavy Weight Component . Swing : - It has a Platform Independent Look and Feel . - And its because it

Adding JPanel to JFrame

十年热恋 提交于 2019-12-03 06:57:39
I have a program in which a JPanel is added to a JFrame: public class Test{ Test2 test = new Test2(); JFrame frame = new JFrame(); Test(){ ... frame.setLayout(new BorderLayout()); frame.add(test, BorderLayout.CENTER); ... } //main ... } public class Test2{ JPanel test2 = new JPanel(); Test2(){ ... } } I get an error asking me to change type of 'panel' to 'component'. I do I fix this error? It wants me to do: Component panel = new Component(); public class Test{ Test2 test = new Test2(); JFrame frame = new JFrame(); Test(){ ... frame.setLayout(new BorderLayout()); frame.add(test, BorderLayout

Java slow 2D performance - Resizing

China☆狼群 提交于 2019-12-03 03:09:09
I am using Windows 7 with Aero, and have a very fast graphics card (Radeon 6870) that I use for gaming. I have some issues when resizing very simple programs I make with java. For instance, this program does absolutely nothing. It has no action listeners, no loops. It's simply a GUI interface with buttons. Resizing with OpenGL acceleration off: [View fullscreen] It takes about a second to resize the components. For me that's very noticeable. Resizing with OpenGL acceleration on: I have tried to enable OpenGl acceleration to solve this problem. I compiled the JAR and run it with java -Dsun

Disable Background drawing in JFrame in order to properly display Aero (DWM) effects

。_饼干妹妹 提交于 2019-12-03 02:39:23
I'm having problems using the DWM functionality of Windows Vista/7 on Java windows. I want to make the background of my frame use the Aero style. The Windows API to do so is provide by the function DwmExtendFrameIntoClientArea in the dwmapi library. I've managed to call the procedure properly via JNA, and it does what it is supposed to do (You can see that for example when resizing the frame, before the next repaint you see the proper aero effects in the area not yet painted, see the attached image). But somewhere (I can't figure out where) a background is painted over the Aero effect and the

Set location of JDialog relative to JFrame

我们两清 提交于 2019-12-03 01:20:15
Is there a way to set a dialog location relative to a JFrame ? I would like to center the dialog to the frame that houses my GUI, instead the dialog often appears in the center of the screen rather than within the GUI. Is there a way to set a location relative to another JFrame You can: pass JFrame as argument for JDialog.setLocationRelativeTo(Component c) set to desired Point from JFrame to JDialog.setLocation(Point p) EDIT all Swing code must be done on EventDispatchThread , meaning that setVisible(true) should be wrapped into invokeLater EDIT2 when using the JFrame as Component c I am

Adding jlabel to a jframe using components

混江龙づ霸主 提交于 2019-12-03 01:13:33
问题 I have 2 classes, My main class creates a frame and I want another class to add content to it. A bit of reading arroudn told me I should use components to do this however when I run my code the frame is empty. public static void main(String[] args) { // create frame JFrame frame = new JFrame(); final int FRAME_WIDTH = 800; final int FRAME_HEIGHT = 600; // set frame attributes frame.setSize(FRAME_WIDTH, FRAME_HEIGHT); frame.setTitle("My Frame"); frame.setVisible(true); Component1 Com = new