jframe

Custom design for Close/Minimize buttons on JFrame

Deadly 提交于 2019-12-01 07:34:02
问题 I would like to apply my own close and minimize buttons. Is there any way to change the JFrame design? 回答1: The trick lies in the PLAF and setDefaultLookAndFeelDecorated(true) (Specifying Window Decorations). E.G. import java.awt.BorderLayout; import javax.swing.*; public class FrameCloseButtonsByLookAndFeel { FrameCloseButtonsByLookAndFeel() { String[] names = { UIManager.getSystemLookAndFeelClassName(), UIManager.getCrossPlatformLookAndFeelClassName() }; for (String name : names) { try {

Java JTabbedPane Inset Color

孤人 提交于 2019-12-01 06:56:10
I was wondering how you would get the color of the inset of a JTabbedPane. I cannot seem to get this color. Every attempt I make I get 236,236,236 which is the outside frame color, where the inside frame color is about 10 darker, 227,227,227 (using the built in apple color meter). I am setting the look and feel using UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); You can see this in an image that I found on the internet. http://pagesofinterest.net/wordpress/wp-content/uploads/2009/06/Quaqua-Maven-Netbeans.jpg Where the words "Panel's Title" is the area that I am getting

Black square showing when adding a .GIF on JPanel

百般思念 提交于 2019-12-01 06:46:53
My problem is that when adding a .GIF to a JPanel, it shows this black square background for the .GIF. Result when adding on JPanel: It happens when I use this line: p2.add(loadBar); // where p2 = new JPanel(); However, when I add the same .GIF on the JFrame, the black square is not there anymore. Like this: jf.add(loadBar); // where jf = new JFrame(); Result when adding on JFrame: Part of the class code: String loadLink = "http://i.imgur.com/mHm6LYH.gif"; URL ajaxLoad = null; try { ajaxLoad = new URL(loadLink); } catch (MalformedURLException e3) { // TODO Auto-generated catch block e3

Will new instance of JVM or reflection help in this case

走远了吗. 提交于 2019-12-01 06:37:36
问题 I had a problem that I posted before but got no clear solution How to prevent JFrame from closing. So I am posting a SSCCE may be this might help in better understanding the problem being faced package myApp; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import javax.swing.JFrame; import App2.Applic2; public class MYApp { @SuppressWarnings({ "unchecked", "rawtypes" }) public static void main(String arg[]){ JFrame f = new JFrame(); f

JPanel custom drawing using Graphics

≡放荡痞女 提交于 2019-12-01 06:31:04
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 correctly defined (from getWidth() and getHeight()). Why would this sometimes work and sometimes not work? What

set title to JFrame

偶尔善良 提交于 2019-12-01 06:28:57
I am new to Java. My problem is that I have a class names MyClassExp. I have extended it from JFrame. Inside the class, I initiate an object of another class named TabbedFrame. TabbedFrame also extends a class DemoFrame . In DemoFrame, I have the title of the page set using keyword 'super' like: super("Some Title"); Now when I run my MyClassExp, even after creating a JFrame as: new JFrame("New Title"); I'm still getting the same title i.e Some Title. Is there any way to solve this problem? I've tried a lot to solve it but failed :'( Use the API method public void setTitle(String title) . -

JFrame to image without showing the JFrame

我的梦境 提交于 2019-12-01 06:18:06
I am trying to render a JFrame to an image without ever displaying the JFrame itself (similar to what this question is asking). I have tried using this piece of code: private static BufferedImage getScreenShot(Component component) { BufferedImage image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB); // call the Component's paint method, using // the Graphics object of the image. component.paint(image.getGraphics()); return image; } However, this only works when the JFrame 's setVisible(true) is set. This will cause the image to be displayed on the

Java how to make JFrames maximised but not resizable

笑着哭i 提交于 2019-12-01 06:06:50
Originally (See my previous question " Java how to make JFrames start off as a maximised window ") I wanted to make a window which starts out maximised. This code accomplishes this: public static void main(String[] args) { JFrame frame = new JFrame(); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setVisible(true); } However, if this window is restored down it becomes a practically non-existent bar. To solve this I set a size for the window using setSize(). This works but presents another problem, the window can still be resized. To solve this problem I set setResizable(false); and this

JFrame to image without showing the JFrame

心不动则不痛 提交于 2019-12-01 06:03:15
问题 I am trying to render a JFrame to an image without ever displaying the JFrame itself (similar to what this question is asking). I have tried using this piece of code: private static BufferedImage getScreenShot(Component component) { BufferedImage image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB); // call the Component's paint method, using // the Graphics object of the image. component.paint(image.getGraphics()); return image; } However, this

DragTabFrame closing inconsistently

妖精的绣舞 提交于 2019-12-01 05:50:29
The code below is supposed to work a little like the Multi-Document Interface (MDI) you might see in a browser like FF, IE or Chrome. It presents 'documents' (a black buffered image as spacer) in a tabbed pane such that they can be dragged from the pane into a new (or existing) window by user choice. But it has had issues with closing frames once they have no more tabs, as well as closing the JVM when there are no further visible windows. I think I fixed them by checking with a Timer in the DragTabManager : It checks open frames for instances of DragTabFrame If it finds one, it check the tab