Hello,
I'm experiencing a subtle issue with the Swing SystemLookAndFeel under Windows 7. The applet below sets the SystemLookAndFeel and then modifies the background colour of MenuBar and MenuItem. This works perfectly well with Windows XP and it works also well with Windows 7 having the Windows Classic theme activated. But it has no ef...
Hi, I'm trying to create a JSpinner to enable the user to pick a Date. I want there to be a lower date limit and an upper date limit. I also want the initial value to be the lower date limit. Unfortunately, My problem is that it won't let me use the lower limit as the initial value (the JSpinner simply becomes unresponsive). Here is my c...
I have these progress bars:
I'm trying to set the color of the TEXT of the progress bars, without changing the background color or the color of the progress bar itself. As far as I can tell, setForeground() sets both the text and the bar color? Is there a way to do one without the other?
...
I am writing an application that is a virtual notebook. The idea is to have panels with various content (which is based on an external file) added to a panel that acts as a page. Once that page is full, its specialized add method should return false.
The problem is that I can't figure out how to accurately determine the size of the pane...
Oh hay there, didn't see you. I was wondering if there is a better, more efficient way of formatting the labels, panels, and buttons in java then what I have done below. Here is my code, I want to make Welcome, the date, and the button to all be on separate lines. And the only logical way of doing so is creating blank labels, right?
pri...
I want to do one thing in Swing, I hope I will be clear enough.
I want to display a list of files with the icons, that the user have associated with that particular file, based on extension. However, I want this list of files be generated in the program - by that I mean: the displayed file icons will not be actual files in a folder (so...
I realize, if I didn't not include line
jComboBox1.addItem("Cause Text Field To Override");
When I type in "A" in JComboBox's text field, "A" will shown in JComboBox's text field.
However, If I include the addItem code, JComboBox's text field will be override. (The lower boundary line also dissapear, not sure why)
I wish to able...
Good evening,
I'd like to know how to get the size of a JComponent after it's been laid out with a LayoutManager. I've read that this is possible, if you just call dolayout(), validate(), or setVisible() beforehand. However, I can't get it to work in my code.
The reason I'd like to know this is to only add as many components as will fi...
If I really wanted to do something like that, can I put a JProgressBar (or it's equivalent) in a JTabbedPane tab? (I mean, not in the tab itself,
How would I do something like that?
EDIT I really do want to put the progressbar in the title of the tab, not the tab itself.
Here's some ascii art:
--------------------------------------...
I'm new to Java, I'm coding on NetBeans. The problem is that whenever I disable a control
i.e jmenu.setEnabled(false) it still fires events! holy crap! how is it! :P
How can I prevent it?
...
Hi,
I have a question regarding quick initialization of swing components. At the start of my swing application I have a window that pops up with buttons that allow the user to do a variety of things. Is there I way that I can quickly launch that first window and load the rest of the UI (such as other frames and dialogs) in the backgroun...
Hi,
This is not a huge problem but I am wondering if there is a solution. In the example below a window opens with a button and if you press that button another window opens, in Windows 7 it does a little effect when it opens. When you close the new window it does another effect for closing. If I press the button again it just pops up w...
I want to add/hide/remove jlayeredpanes dynamically on runtime and also should hide the contents on each pane when another pane is selected. I have tried the following code and i am not sure how to do this. The following code hides the content of each pane when alternate pane is selected but it does not hide its content constantly. When ...
How do you resize a JButton at runtime so it adapts to the text given by setSize? I've done some searching and this is the code I've come up with so far. Could this be turned into a utility method?
FontMetrics metrics = getFontMetrics( font );
int width = metrics.stringWidth( string );
P.S: No layout manager is being used.
...
I am creating a Java applet, and I am trying to add a JFrame to it. I am calling:
add(new MyJFrameSubclass());
But when I launch the application, my JFrame isn't shown until I resize the window.
...
Hi folks,
I am curious whether it is good practice to make a new main JPanel object every time a user wishes to return to that JPanel from a subsequent JPanel?
FYI, my Swing application has a JFrame whose first object is a mainJPanel with three JButtons (one of them is a Review button).
Let's say the user pushes the Review button. The...
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...
Hello all,
I'm using Java AWT to draw lines on a panel (Line2D & and Graphics2D.drawLine) and I'm wondering how I can draw a line with tick marks, similar to:
|----|----|----|----|----|
I know the positions I'd like to draw the ticks at in advance.
The lines could be in any position, so the ticks must be drawn at an angle releative t...
I have a JComponent that does custom drawing, and overrides the following methods:
public Dimension getPreferredSize() {
return new Dimension(imageWidth, imageHeight);
}
public Dimension getMinimumSize() {
return new Dimension(imageWidth, imageHeight);
}
Where imageWidth and imageHeight are the actual size of the image.
I ha...
I am working on a Swing application in which I am trying to display an Applet (processing PApplet) inside of a JFrame. The frame has a JMenuBar attached to it. When I click on the menubar, the menu items are being shown behind the applet. Does anyone know what's going on here and a workaround? I didn't see anywhere where you can set the ...