jframe

Why do the JButton in my dialog look weird

I'm fairly new to Java Swing/AWT et al and hence the question. I have a simple dialog with some text and a couple JButton. I am using the GridbagLayout for this dialog. But when I look at the dialog, the JButtons are kind of having a weird shape and I cannot seem to right justify the text either. Is this a limitation of the Layout I ...

How to judge a window exsits?

could return boolean? I want to new a JFrame if the JFrame not exsits,but not to new if exsits. I creat a Map to save JFrame's name. ...

How to Set Multiple Components Visible on a JFrame ?

When I add more than one component on the JFrame , only the component which was added last is displayed , rest are not displayed , what is the issue with their visibility ? import java.awt.GraphicsEnvironment; import java.awt.Point; import java.awt.*; import javax.swing.JFrame; import javax.swing.JButton; import javax.swing.JLabel; publ...

How can I preset a JFrame?

Hi, using an external library which creates a JFrame window, there is a way to preset its l&f before showing it? also something like accessing its own thread could be a solution (via reflection I mean)? Another question, time ago I watched some JFrame having custom aplha borders (some shape applied), could you tell me if it was a supp...

What affects the enabled status of the zoom button on a JFrame for Mac?

I have a Java program that I wrote that changes whether or not a JFrame is resizable depending on application state. In Windows this works great, when it is resizable the maximize button is enabled when it's not the button is disabled. However, on my Mac when I change resizable back to true the zoom button does not become enabled but the...

Building a GUI for a Sudoku Solver (Complete with ASCII Example)

. OVERVIEW, SAMPLE Hello everyone, I have created a basic Sudoku solver that can solve most problems fairly quickly. I still have a lot of work ahead of me to make it solve even the hardest problems, but I'd like to try to implement a basic JFrame GUI first. I have worked with internet applets in the past, but never before with JFram...

Multiple frames in a Java application

Just need some quick guidance - I have a main frame, and I want some smaller frames inside of it that can be dragged outside of the main frame (potentially onto multiple monitors). When dragged back in, they should not be hidden behind the main frame when the main frame is clicked on. I'm unclear about what I should be using... JFrames...

java jdialog taskbar button

hi, i'm traying a jdialog on linux, but it still appears in my taskbar. this is the code? what's wrong? import javax.swing.JDialog; public class Main { public static void main(String [] args) { new mydialog(); } private static class mydialog extends JDialog { public mydialog() { super(); ...

Minimizing a supplementary JFrame when main application JFrame gets minimized

The application I'm working on contains a main JFrame, from which users might eventually open another supplementary frame. I am trying to implement such a behavior of the app where the supplementary frame is minimized (iconified) as soon as the main frame gets minimized. I was thinking of overriding the setExtendedState method of the ma...

Java: Handling event on component inside a seperate JPanel component

Hey guys, So I have a JFrame which I've added a custom JPanel component. The JPanel component has a button that I want to attach a listener to in my JFrame. What is the best way to do this? ...

Java: JFrame.setLocationRelativeTo(null) not centering the window on Ubuntu 10.04 / gnome 2.30.2 with OpenJDK 1.6.0_18.

Sample code: JFrame jFrame = new JFrame("Test"); jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jFrame.setLocationRelativeTo(null); jFrame.setSize(600, 600); jFrame.pack(); // jFrame.setLocationRelativeTo(null); // same results jFrame.setVisible(true); Is this the OpenJDK's fault? I recall hearing...

JFrame and why stay running

Why if I create a JFrame then the program still runs until (i.e) I close it with the small "exit button" of the window? I looked for this answer and I failed. The only thing I guessed is that when I do "new JFrame()" it's like an special "new", that keeps a reference of the object in the EDT, so it will always be referenced (even if was...

Difference between JPanel, JFrame, JComponent, and JApplet

Hi, im making a physics simulator for fun and i was looking up graphics tutorials when i tried to figure out the difference between all these J's. could somebody elaborate on them or perhaps provide a link to a helpful source? ...

Maximizing a JFrame on action?

Hey all, Does anyone know how to maximize a JFrame once a specfic action has occured? I'll post my code below, I'm a fiend for not commenting my code (I'll do it at some point) but it should be fairly self explanitory. What I was trying to do was to get the frame to maximize once the option was selected from the menu. If anyone can tell...

actionlistener returning a nullexception on jbutton

I have an action listener set up on my main jframe menu for the buttons listed on it, and they work fine, bringing up other jframes as needed. The problem is when a person clicks the buttons on the jframes brought up I get a nullexception after a jbutton is clicked on that submenu jframe. Example code: public class main extends JFrame...

Position a Jpanel In the middle of a Jframe or Another Jpanel

I am making a card game atm, and i want the card stack to be placed in the middle of a Jframe. Right now i have made the cardstack in a layeredPane. And that layeredPane is placed in a panel. And i want that panel to be placed in the midle of the frame, or the contentpanepanel.... Please help guys... I dont want more sleepless nights...

Java JFrame: Image not displayed

Hi everyone, Im trying to build a small frame that displays an image. My problem is that in the paint(Graphics g) method, the g.drawImage is executed, but nothing is shown on my RLFrame. Any thoughts / tips? Thanks in advance. Here's the code public class RLFrame extends JFrame{ Image img; public RLFrame(String title){ super(...

Listening for action on internal JPanel from a JFrame

Hi, I have a JFrame that has a BottomPanel (a class I made that extends JPanel) inside it. And inside that JPanel is another JPanel called DicePanel(that again extends JPanel). In DicePanel there is a button called 'End Turn' that when clicked should end the players current turn for the board game the program is based on. I want to some...

Displaying a JComponent inside a JPanel on a JFrame

I am failing to display a JComponent inside a JPanel on a JFrame. The following does not work. JComponent component = ... panel.add(component, BorderLayout.CENTER); frame.add(panel, BorderLayout.CENTER); But if I add the JComponent to the JFrame[like frame.add(component, BorderLayout.CENTER);], it displays the contents. Any ideas ...

How to intercept keyboard strokes going to Java Swing JTextField?

The JTextField is a calculator display initialized to zero and it is bad form to display a decimal number with a leading 0 like 0123 or 00123. The numeric buttons (0..9) in a NetBeans Swing JFrame use append() [below] to drop the leading zeros, but the user may prefer the keyboard to a mouse, and non-numeric characters also need to be ha...