jframe

Change brightness of jframe

耗尽温柔 提交于 2019-12-11 04:49:33
问题 I have a program, and it runs in a jframe in full screen exclusive mode. I am trying to change the brightness of the jframe. I was wondering how i would implement this. I thought it might be possible to change all the colors of the images getting drawn to the jframe and make them brighter, but it still does not change how bright the screen actually is. How do programs normally implement something like this. 回答1: At the end of your draw loop: g.setColor(new Color(0, 0, 0, 0.5f)); // 50% darker

How to work with a specific element in GridLayout?

删除回忆录丶 提交于 2019-12-11 04:43:39
问题 I have a problem adding an icon to a spesific element(grid?) in gridlayout. My gridlayout contains 64 "bricks" which is intended to work as a chessboard. My gridcode looks like this: ChessBoard public class SjakkBrett extends JFrame implements Config { public ChessBoard() { setSize(800,800); setLayout(new GridLayout(BRICKS/ ROWS, 0) ); for (int id = 0; id < BRICKS; id++) add(new Brick(id)); setVisible(true); } Config public interface Config { public int ROWS= 8; public int BRICKS= 64; } My

Unable to Add an Action Listener to JButton

戏子无情 提交于 2019-12-11 04:42:45
问题 I haven't touched Java in a few years and now I'm back, trying to make a GUI to test out JFrame. I am attempting to create a JButton that will close the program when clicked. With the current code I am receiving the error "The method addActionListener(java.awt.event.ActionListener) in the type javax.swing.AbstractButton is not applicable for the arguments (new ActionListener(){})" . The other questions I have found deal with multiple classes or other issues that don't help with my problem.

Why does a JButton not show unless text is set after JButton is added to JPanel?

▼魔方 西西 提交于 2019-12-11 04:33:01
问题 I have a problem with my JButton objects behaving in an odd way: JFrame frame = new JFrame(); frame.setSize(new Dimension(200, 200)); frame.setVisible(true); //Constraints GridBagConstraints constraints = new GridBagConstraints(); constraints.weightx = 1.0; constraints.weighty = 1.0; ... // JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); JButton button = new JButton("Categories:"); panel.add(button, constraints); frame.add(panel); This results in the following GUI: Where is

Add a JScrollPane to a JFrame

谁说我不能喝 提交于 2019-12-11 04:06:38
问题 I have a question in relation to adding components to a Java frame. I have a JPanel with two buttons and also a JScrollPane that has a JTable added to it. I am wanting to add both these to a JFrame. I can add either the JPanel to the JFrame, or the JScrollPane to the JFrame and they display correctly. I am having trouble adding them both to the JFrame and displaying them both. Is there something related to JFrames that do not allow this? Any help will be appreciated. EDIT The problem is not

JFrame wrong location with Ubuntu (Unity ?)

淺唱寂寞╮ 提交于 2019-12-11 03:38:14
问题 It seems that there is a bug with Ubuntu (maybe only unity). The decoration of the JFrame is taken into account for getLocation() and getSize() , but not for setLocation() and setSize() . This leads to weird behaviour. For instance, if you use pack() after the frame is displayed and the dimensions changed, the frame will go down 20 pixels... To illustrate a concrete case when it becomes really annoying, I made a SSCCE. It's a JFrame with a basic JPanel. If you drag the panel, the JFrame is

Why is my JFrame not appearing in a web based Java app?

空扰寡人 提交于 2019-12-11 03:32:43
问题 I have a game application that I will be running in a web browser using the tag. This program has a JFrame, which displays a couple of tabs allowing navigation throughout the program. When I run the program locally it will work fine, displaying the JFrame and working in entirety. However when I upload it to the host and visit it's link the JFrame will not display.. I have searched about 3 hours and simply must not be able to provide the correct keywords for my siutation. All I can get in

JFrame getLocation and setLocation deal with system border differently

☆樱花仙子☆ 提交于 2019-12-11 03:26:46
问题 I am creating a multi-user Swing GUI application, and want the user's window location and size settings to persist when they log out and back in. I am currently getting the window location and size using the getLocation() and getSize() methods on my parent JFrame when the user logs out and saving them to a file, and then when the user logs back in I read those values back in and set the window size and location using setLocation() and setSize() . The problem that I am having is that

How to set a JFrame location beside another JFrame?

岁酱吖の 提交于 2019-12-11 03:14:38
问题 In Java, how could I set a JFrame to automatically go beside another JFrame? So, say I have two JFrame objects, frameA and frameB , and when the program runs, it sets frameA s location to be in the middle of the screen by using: setLocationRelativeTo(null); Now what I want is to make frameB to be on the right side of frameA , so they would be right beside each other. ( frameA s right side would be touching frameB s left side) How would you do this? 回答1: This is a test class I created to

focus for java applets

寵の児 提交于 2019-12-11 03:06:39
问题 I made a java game that is all based on JPanel. When I add it to a JFrame it works perfectly, and when I add it to a JApplet and test it with the built in applet tester of eclipse it works perfectly. However, when I try to run the applet through an html site it doesn't work. It loads, but it doesn't take keyboard input. I have it set up where "pressing s" starts the game, but even when I click on the game and press s, nothing happens. Do I have to set the keyboard focus, because I thought