This question already has answers here:
Changing the JFrame title
(4 answers)
Closed 4 years ago.
I am a beginner and I designed a frame but I didn't do it manually. Instead I used the design tool in Netbeans. I am trying to set a title with the following code in my main method but I still wont get it.
...
/* Create and display the form */
java.awt.EventQueue.invokeLater(() -> {
new QueuesFrame().setVisible(true);
QueuesFrame.SetTitle("myCase senario");
});
}
Java is case sensitive, so SetTitle should be setTitle and you need to perform the operation on an instance of the frame
QueuesFrame frame = new QueuesFrame();
frame.setTitle("myCase senario");
//frame.pack();
//frame.setLocationRelativeTo(null);
frame.setVisible(true)
Instead I used the design tool in Netbeans
If you interested in become a decent developer, I would strongly recommend avoiding the form editors until you have a better grasp of how the Swing (or even JavaFX) APIs actually work - it will give you a better baseline of skills and reduce the mess that form editors get you into
Related
This question already has answers here:
How to implement draggable tab using Java Swing?
(5 answers)
Closed 4 years ago.
I want to be able to move my tabs in my jTabbedPane left or right to change the sorting order. I looked around but I noticed most of what I found is asking how to drag and drop a tab in. I just want to make it resortable so that I can move the rightmost tab to the left of the leftmost tab or any order I want.
I know for table columns in a JTable, there is a method, something along the lines of
JTable table = new JTable();
table.setReordering(false); //disables reordering of columns
which prevents this so this functionality is already enabled with columns in tables but with tabs in JTabbedPanes, I cannot find any method similar to this but I'm thinking it would be something similar like
tab.setReordering(true)
as well but I don't see anything.
A quick search, yielded that it doesn't seem to be supported by Swing directly.
Though this is fairly common with GUI frameworks, where you are often left to implement certain functionality yourself (e.g. I recently had to manually implement TreeCell to allow context menus on TreeItems). This prevents libraries from becoming monolithic unmaintainable messes.
You can find an implementation of the drag-and-drop functionality here
This question already has answers here:
How to go back to a JFrames in Java
(3 answers)
Closed 7 years ago.
When I open a new JFrame, I set the old one as false:
ExampleJFrame.this.setVisible(false);
ExampleNewJframe newOne = ExampleNewJframe();
newOne.setVisible(true);
But If I am in newOne, how do I get back to the original Frame without creating a new as I did above?
The best solution: don't go swapping JFrames; that's can be a rough design that can annoy users. Instead swap JPanel "views" using a CardLayout as per The Use of Multiple JFrames, Good/Bad Practice?.
This question already has answers here:
How to control the JavaFX Tooltip's delay?
(8 answers)
Closed 7 years ago.
I have tried Using
1)
import javax.swing.ToolTipManager;
ToolTipManager.sharedInstance().setDismissDelay(20000);
at various locations in *.java file (using NetBeans IDE)
2) Creating OnMouseEnter MouseEvent Handler Override routine including:
ToolTipManager.sharedInstance().setDismissDelay(20000);
Results: No Errors, Runs fine, Except Display Time is ALWAYS 5secs!!!
I would prefer NOT creating my own Popup Control, because I like all the Behavior of existing Tooltip, except Im trying to Display Several words in Tooltips that User Needs to take Long Time to Read. Please Help!!!!!
You're calling a Swing utility class, i.e. import javax.swing.ToolTipManager, this has no control over JavaFX functionality.
According to control JavaFX Tooltip delay, this is not supported and the subject of a change request. That question also contains a reflection based 'hack' and another workaround involving popups.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
“Always on Top” Windows with Java
I am using JFrames
I have a window(ex-Accounts) which gets called from a button in MainMenu.
As long as Accounts is opened i want to forbid the user from accessing MainMenu(which should be visible) unless he closes the Accounts window.
This means that you need your window to be modal. JDialog can be modal, you can either mention this in the constructor like this:
new JDialog(parent, true);
or starting with Java 1.6, you can set the ModalityType:
new JDialog(parent, modalityType);
This question already has answers here:
How to set Icon to JFrame
(12 answers)
Closed 6 years ago.
I want to know that how to change the image in the upper left corner in a java program and in the taskbar.
See the screenshot to know what i am talking about-
http://www.ougfiles.com/dl/303275944/Untitled.jpg
I think you're looking for Window.setIconImage, where the "window" will probably be a JFrame if this is a Swing app.
Note that there's also Window.setIconImages which allows you to set multiple images, so that it can pick up different resolutions for different situations (e.g. a bigger icon in the Windows task bar than in the frame itself.)
Use setIconImage() or setIconImages(). The latter lets you specify a list of icons in different resolutions; the most suitable one will be used in each case (desktop, taskbar, title bar of the frame, etc.)
See also the this section in the Java tutorial.
Quick Google searched revealed a setIconImage for your Frame
frame.setIconImage() (oracle.com)