jframe

Transparent JFrame background

人走茶凉 提交于 2019-12-04 05:05:36
Is it possible to make a JFrame that has a transparent background and draw an image on it, so only the image will be visible with no border or background? McDowell See Translucent and Shaped Swing Windows by Kirill Grouchnikov. Yes, it's possible in many ways. This is one of them: setUndecorated(true); setBackground(new Color(1.0f,1.0f,1.0f,0.5f)); 4th float (which I set to 0.5f) in Color's constructor is alpha channel. It can be 0.0f - 1.0f depend on transparency you want. Taylor Golden It is possible. If your JFrame is a local variable or field: myJFrame.setUndecorated(true); If your class

Why doesn't my JFrame repaint when I set a new Synthetica theme?

守給你的承諾、 提交于 2019-12-04 05:03:13
问题 I just set my applications theme to Synthetica Alu Oxide but some reason the JFrame doesn't repaint but another Synthetica theme will repaint the JFrame. This is what mine looks like. http://i.imgur.com/SOBDTs4.png This is what its suppose to look like. http://www.jyloo.com/images/screenshots/syntheticaAluOxide/democenter2.png public MainPanel() { JFrame frame = new JFrame(); frame.setTitle("Asteria 3.0 NPC Definition Editor"); try { UIManager.setLookAndFeel(new SyntheticaAluOxideLookAndFeel(

Does placing setVisible() function in the beginning of the function be different when I placed it at the end of that function?

非 Y 不嫁゛ 提交于 2019-12-04 05:02:55
问题 I'm just new to Java GUI Programming and I'm having a problem that the components inside my panel is missing when I place the setVisible() function at the beginning of the function called by the constructor but it works fine when it is at the end. See code below: public static void main(String[] args) { new MainClass(); } public MainClass() { setFrame(); } private void setFrame() { JFrame frame = new JFrame(); frame.setSize(400,400); frame.setResizable(false); frame.setVisible(true); frame

java fullscreen window with transparency

只愿长相守 提交于 2019-12-04 04:44:52
I am trying to create a fullscreen window that cover the whole screen using Java. This window must also have some transparency (about 30%-50% transparent). When saying whole screen, I do mean it cover everything (including the dock/taskbar/menubar in OSX/Linux/Windows), and when I say with transparancy, I mean a real-time transparancy and not just a hacked screenshot. Here is what I am aware-of/tried: Using Java Fullscreen API: while it creates a true fullscreen, you cannot have some transparency with it (only opaque color). One hack is to take a screenshot of the whole desktop and set it as

Why is calling JFrame.pack() adding extra space?

荒凉一梦 提交于 2019-12-04 04:42:09
问题 Originally, the code I was using worked fine, but was a bit convoluted. After moving some parts of a method into the constructor for the JFrame, things were working properly. Everything except using pack() to make the frame the proper size. Here is the original code: public class BaseGameFrame extends JFrame { public static final int WINDOWED = 0; public static final int UFS = 1; protected BaseGamePanel gamePanel; public BaseGameFrame(String title, int pWidth, int pHeight, long period, int

Java: how to register a listener that listen to a JFrame movement

六月ゝ 毕业季﹏ 提交于 2019-12-04 04:39:11
问题 How can you track the movement of a JFrame itself? I'd like to register a listener that would be called back every single time JFrame.getLocation() is going to return a new value. EDIT Here's a code showing that the accepted answered is solving my problem: import javax.swing.*; public class SO { public static void main( String[] args ) throws Exception { SwingUtilities.invokeAndWait( new Runnable() { public void run() { final JFrame jf = new JFrame(); final JPanel jp = new JPanel(); final

how to use jpanel with paint (or repaint)

僤鯓⒐⒋嵵緔 提交于 2019-12-04 04:27:41
问题 I'm a newbie to the paint/graphics and wonder how to add a JPanel to my code in such way that the entire graphics will be on a JPanel and not on the JFrame. In other words, I'm trying to create a GUI that will allow me to do this: on the RIGHT side show the nice movement of the lines on a JPanel on the LEFT side, add a JTextArea (on a JPanel) that will show the coordination of the graphics. This is a simplification of a bigger problem but I guess the code here is easier to understand. Thank

java多种文件复制方式以及效率比较

会有一股神秘感。 提交于 2019-12-04 04:17:29
1.背景 java复制文件的方式其实有很多种,可以分为 传统的字节流读写复制FileInputStream,FileOutputStream,BufferedInputStream,BufferedOutputStream 传统的字符流读写复制FileReader,FileWriter,BufferWriter,BufferedWriter,BufferedReader NIO系列的FileChannel FileChannel+缓冲 java.nio.Files.copy() 第三方包中的FileUtils.copy方法,比如org.apache.commons.io.FileUtils,org.codehaus.plexus.util.FileUtils等等. 所以呢,看看各种方法效率怎么样,主要衡量的标准就是时间,另外的一些标准包括大文件的复制时的内存溢出等问题. 2.概述 由于很多时候复制文件都包括了文件夹下的所有子目录及文件的复制,所以作者采用的遍历+复制方法去复制文件.就是把整个复制过程分为先遍历,遍历的过程中遇到文件夹就创建,遇到文件就调用不同的复制方法. 遍历的5种方法: (1)File.listFiles() (2)File.list() (3)org.codehaus.plexus.util.FileUtils.getFiles() (4)org.apache

How to open a new window by clicking a button

浪子不回头ぞ 提交于 2019-12-04 04:04:25
As a part of my program, I need to have a button that when the user click on it, it opens a new window. Well I guess I should have a class that make the frame and call it by the button. but I don't have any idea to start. I just got my button in the program, but it does not work. So can some tell me how to do it? or code it. Here is a simplified version of what you want to do: JButton button = new JButton("New Frame"); button.addActionListener( new ActionActionListener() { public void actionPerformed(ActionEvent e) { // Create a method named "createFrame()", and set up an new frame there //

Java adding ImageIcon to JLabel

◇◆丶佛笑我妖孽 提交于 2019-12-04 03:50:35
I am trying to make a very basic game with Java and I am having trouble displaying an image on a JFrame . It has worked in the past for me and now is not, i can't see what I did wrong. I have tried printing the current working directory and changing where I get my image to match that. It is likely that the problem is not getting the image, since my (filefinder or filereader or something like that) can find it without problems, but I cannot correctly add it (the ImageIcon ) to the JLabel , or that to the JFrame . This is my code... JFrame frame = new JFrame("no image"); ImageIcon image = new