I am creating a chat application using JApplet. I have a TextArea where all chat messages go. Everything in working fine and smooth just as you would expect a basic chat application to do. Now i want to add support for gestures. I wanted to know, how can we show an icon in TextArea? it only takes string in append() method.
You should probably be looking at JTextPane instead of JTextArea.
Have a look at this tutorial which among other things, gives this demo:
Related
Well I need to show text messages directly on the screen.
I tried searching a lot but found nothing that could solve my problem.
The options I found on the interner:
To use a JFrame and render text on that.
To print text on a console.
But the problems with these here I do not want any window to pop up.
I also want the text to be on top of all.
My attempt:
As far as my tries here it is :
Here is what it should look like:
As you can see my try is far from what I want.
Well is there a better way? Is it possible Without any Frames?
Well this could be similar to Toast messages in Android.
I did achieve what I intended.
Here is the link to the GitHub Repository : https://github.com/Jaysmitio101/jsubs
This is a Java Library for showing subtitles on any screen and also show messages like Toast messages in android.
I have a calculator application in java swing, which is working properly with mouse click input. Now I want it to read input using keyboard button stroke. I had heard about the glass pane in java tutorial, but i need to know any other simple method to meet the requirement.
KeyPadPanel is an example that uses Action and Key Bindings for numeric entry.
I created a text-based game similar to Zork and I need a gui to run it outside of Eclipse. I want to run it as a jar. (by the way I'm on a mac if that changes anything). I only need an output field and an input field. What would be the easiest way to achieve this?
And how much of my code would I need to change? (I used System.out.print for output and a Scanner for input)
If you want to crate GUI like console the simple way to do it is to add textarea component to your frame or or panel that has scroll bars through the viewport. Create a stream that feeds the component with text. Then simply redirect standard output to that stream. Finish. Start your GUI and enjoy the console.
If you don't want to run this on a terminal, you should probably use Swing with a JTextArea in which you append all the messages to the user, and a simple JTextField for the user to enter his commands.
Here's a quick example of JTextArea so you get an idea. You'll need to read more about events on Swing to make things like reacting to the user pressing the ENTER key to read the contents of the text field and run the game logic.
Note that the screenshot on the example above uses the "Metal" look and feel, but it should look much closer to a native application on the Mac.
I have a question.
I just started with Java and may have some small basic things. Now I wonder how a kind of pages (sections) in a program makes.
I do not mean some kind of tabbed panel, or if you click on a button that a text is visible.
I mean that for example all over the screen a separate part of the program looks. As the main menu of a game.
There is nothing else than the main menu visible at that time. If you for example a button from that menu click. The game is loading.
(I'm using the building of a standard game as an example)
If you for example the main menu click on another button (eg "Settings")
Then wort settings "page" is visible, and there is nothing else that the program is really doing.
I do not know how this type of navigation is called. But almost every program does have something.
How can I do this too? What should I do for example, as a new file, import the classes of a particular page, or something?
You seem to be searching for CardLayout. As shown here.
I think you should look for "state machines", which is a way for structuring your code, and implement your menu changing swing components (like JPanel, for example) in a JFrame. If I understand what you want, I think this can be an option.
There is no short answer, but based on your question, you need to read alot. I would suggest the swing tutorial It explains use of Panels, Frames, Layout managers and other containers.
You can also use the Matisse builder in netbeans (relevant plugin in eclipse)
I want to build a MouseDragScrolling like Android over Java for a big touch screen something like this http://jqueryfordesigners.com/demo/scrollable-timelines.html I have this example http://java-swing-tips.blogspot.mx/2008/06/mouse-drag-auto-scrolling.html but i want to use the MouseDragScrolling over a JTable or other component and block and distinct the MouseClick and the MouseDrag.
If you are trying to automate user actions, Look at FEST. It will solve your problem, if you are working on a Swing application.