I want a scrollable console within a JFrame, so people can see messages while using the GUI.
I'm currently using a JLabel, but this obviously only allows one message at a time.
Have you checked the JTextArea Swing component?
This tutorial should help you as there is a scrollable text area in one of the samples: http://download.oracle.com/javase/tutorial/uiswing/components/textfield.html
Use a JEditorPane, it is the most flexible.
I'd suggest you JTextArea or JScrollPane.
Related
my question is very simple. I am creating an app with Java swing, and i realized that the jDialogs doesn´t have maximize and minimize buttons, instead of the jFrame.
There is a way to add it to it? or if not, what can i do if i want to replace the jDialog to another swing component that it has?
Thanks a lot!
To answer my question, i have used the cardLayout to create differents jPanels and including into my jFrame, every time that i want to show another "window" i change it to the corresponding jPanel..
You can see the documentation of cardLayout here:
https://docs.oracle.com/javase/tutorial/uiswing/layout/card.html
I have been researching this topic a lot and haven't found anything that tells me I can add a BufferedImagento a JTextArea or JTextField. I am making a chat application and trying to add smiley faces for the chat. What I am trying to do is put the image right next to the string like it is text. I was thinking if you could put the Buffered image in the format of a char that would help. Please help me! Thank you!
I'd also give a try to JEditorPane.
For motivation see: http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JEditorPane.html.
I've noticed that most of the chat applications, show you what you and others wrote in one window (could be JEditorPane with all the smilies displayed as pics) and bellow you can have editable JTextArea showing just text.
The problem is that JTextArea and JTextField, are really only meant to show text, in order to implement something that mixes thetext with images, you would need to extend JTextArea and modify the paintComponentMethod to do custom rendering.
I'm writing a simple text editor in java, I have done it before now I have some new ideas, normally when I put in a JTextArea when I have a FlowLayout on my JFrame it will fill what is left of the JFrame. However this time it's not. Could someone help me out trying to get it to fill the rest of my JFrame? Thanks!
http://docs.oracle.com/javase/tutorial/uiswing/layout/layoutlist.html
Java does have various layouts. For making dynamic body changes you have to learn more flexible layouts like grid or grid bag layout. Hope this help.
I am new to Java, started learning swing and have a problem with resizing a JPanel inside a JFrame. I am following this tutorial:
http://vincentramdhanie.blogspot.com/2009/11/cardlayout-with-netbeans.html
because ultimately I am learning each of the different layouts and have come to the CardLayout now. In the above, there is a JPanel being used for a status panel. That is what I want to do as well, but when I drag a JPanel onto my blank JForm it takes up all the space and I don't see any resizing handles for it like I would if I were using a .NET panel. Changing preferredSize in the properties window also does nothing. What am I missing here? I feel like a complete noob for asking such a basic question but I really can't find any way to resize this thing.. :-|
EDIT:
I forgot to mention; I am using NetBeans IDE
You can't resize the JComponent because you've select CardLayout. The CardLayout can holds/manages one or more components that share the same display space.
What you need to read documentation and good tutorials.
Assume that the back is using a JTextPane, and I would like to implement a view with a label. But how can I implement the view in Java? is that something like UIView on iPhone on the Java Swing? Thanks.
If I understand correctly, you would like to display a JLabel on top of a JTextPane. If so, use a JLayeredPane.
Read the Swing tutorial on layered panes to learn how to use them.
Are you looking for something like this?
See Twinkle
There's nothing special about this; just pack an extra JPanel along the bottom of your window, and put a JLabel into it; set the text of the JLabel as needed.