I've got an assignment in a class about user interfaces and usability testing. I have to do something that I'm sure I can figure out how to do programatically, but I have no experience with swing so I have no idea what components to use to do the job. My background is in C# so I'm fumbling at times trying to find the right component to use in NetBeans.
Based on the description below, can anybody recommend what kind of text field will do the job? I was thinking jFormattedTextField (based on the name) but I can't seem to figure it out.
Thanks
Submit a Java program that will run on the Linux installation in the general lab (EN-2036).
Provide the following functionality:
load the output of the last command (from a file) into a text viewing area that
allows the user to browse the data
bold all login names only (not the whole line)
bold all occurrences of a user-specified login name
bold all occurrences of a user-specified set of login names
Use JEditorPane or JTextpane, these allow you to add style to text inside them
Tutorial Link
Related
This is my first Java project and I'm not sure where to look/what to search for for information on this question.
I've built Java code in Eclipse using Selenium WebDriver that opens a product page, adds a product to cart, and completes the checkout process automatically. Is it possible to create a GUI with textbox submissions that would insert variables into my already-created code? For example, I'd like to create a GUI that would update my code with the submitted size rather than having to hard-code '6.5' every time as seen in the code below.
wd.findElement(By.xpath("//div[#class='size-options-buttons']/ul//a[#title='6.5']")).click();
Any information or guidance on what to research would be greatly appreciated!
I wouldn't think you would want/need to create a GUI to do this. You should just create a variable that contains the value you want used in your searches and then you can update that value any time you want in only one place.
String title = "6.5";
wd.findElement(By.xpath("//div[#class='size-options-buttons']/ul//a[#title='" + title + "']")).click();
If you wanted, you could read this and other values from a text file, XML, etc.
This is achievable with Java, but its not a part of Selenium as such. You can explore Java GUI frameworks such as AWT, Swing etc, using which you can create your GUI. You can add a text box and button in your UI. Upon click of the button, you can run your Selenium code, where it can fetch the value you entered in the text box as a variable as pass it on to your script.
It all depends on how far you want to take this. You can create very basic UIs with say JavaScript, VBScript as well. These would give you the basic functionality of a text box and button.
You can use an excel sheet also, where you can set these values and pass it on to your script.
Please read before labelling this as a duplicate.
I am creating an application that calculates how fast a person can type by calculating WPM and CPM. However I have hit a snag with the UI as I found out that you cannot really highlight individual strings in a TextArea. My goal is to compare what the user is typing to the random text that is generated by having it so that the text is being dynamically coloured or highlighted as the user is typing.
See http://10fastfingers.com/typing-test/english to get an idea of what I mean
I recently read the following post Highlighting Strings in JavaFX TextArea
I was trying to achieve the same goal of highlighting individual strings inside a javaFX TextArea until I realised that it pretty much is not possible. So I looked into TextFlow which does allow me to edit individual strings. The problem with TextFlow is that all 200 of the generated words would have to appear at once which is not what I want. With a TextArea not all the text has to be displayed at once.
This is what I have so far just so that you can further get an idea of where I am heading with this.
I am currently developing an application for this company as my last year of studies project, and in this application there's this function that allows you to print a paper, so i used the jeditorpane obviously, with the Charles Bell HTMLEditorKit for the predefined functions like setting the font and printing, etc... and there's this pre-written text that i have to load from a text file and then the program is supposed to add some text inside the file automatically, and the user also is allowed to add more if he needs to, or change the font or style or whatever.
So here is the problem, since the predefined text should be already aligned with the font already set and some other properties already in place, and since the txt file doesn't allow that, i tried to use a docx file, which makes the text incomprehensible in the editorpane, i also tried the docx4j api, but then i wouldn't have the HTMLEditorKit menu and functions, (or maybe i could but i don't know how) and the execution of the app becomes rather slow with this api. I also tried this metaphase editor kit which i found it to be really useful with a lot of functions to offer, but i couldn't load a text file to it's textpane.
So my question(s) to be exact is(are):
1)How can i use the charles bell HTMLEditorKit and load a docx file into the edtiorpane in question?
2)Or how can i use the docx4j api with the HTMLEditorKit with the functions menu (style, print, font...) or maybe another predefined menu?
3)Or even better, how can i still use the metaphaseEditorPane with its full of functions menu and at the same time load an existing docx file in its textpane?
Sorry for the long question and any help would count, i would really need and appreciate it.
See Adding custom shapes to JTextpane and saved to new Word document for references to two projects which use docx4j to provide rich text editing of docx within Swing.
I found finally the solution after days of searching and testing, It turns out to be very simple actually.
All i had to do is use a metaphase editor panel, (which has a great toolbar by the way) create a DocxEditorkit and then set the editorkit of the metaphase editor panel's textpane to this DocxEditorKit, although the metamorphose works with HTML text pane, it miraculously worked...
DocxEditorKit DEK=new DocxEditorKit;
MetaphaseEditorPanel MEP=new MetaphaseEditorPanel;
MEP.getHTMLTextPane().setEditorKit(DEK);
//Try and Catch blocks of course to read the file
DEK.read(new FileInputStream(PathToFile), MEP.getHTMLTextPane().getDocument(), 0);
getContentPane.add(MEP, BorderLayout.CENTER);
And that was it... Who thought it would be as simple as this.
I'm looking for a solution to this and I have searched the web for an answer with nothing. I need a scrolling message on my webpage that can be updated by the same website but on a different page. (e.g www.webpage.com <-- has the scrolling message on it, www.webpage.com/settings <-- has a form in which you can change/update the scrolling message)
I'm pretty sure this is achievable with Java, but my knowledge on Java is slim and all my efforts have come to a fail. I have managed to get a scrolling message on my webpage and I'm sure if I could read a text file (with the message in) then assign that to a 'var', I could make that scroll but I don't know how to do that.
If you know a completely different method of doing this I am happy to change mine.
Thanks in advance,
Tom.
I would recommend javascript instead of java, since java is not really conventional anymore and looks ugly too (and requires a special plugin).
It depends on how fast you want to update the scrolling text how you want to do this. I would say save the text to a .txt or database from settings, and then have your page get it.
You can then use php to read the value from the .txt file or database to display it on your website.
If you want it to be extremely up to date you can let javasript call a little .php file that reads the file and gives you the content.
To make your text scroll you don't really need anything other than html, like so:
<marquee behavior="scroll" direction="left">Your scrolling text goes here</marquee>
You can read more about that here: http://www.quackit.com/html/codes/scrolling_text.cfm
As a part of a GUI design that I'm implementing in Java swing, I need the user to be able to select parts or subparts of a tree like structure represented as a string.
For example, if I were to display the following expression, ((a|b)|(c|d))
The user would need to be able to select any of the following
(a|b), (c|d) or the entire thing ((a|b)|(c|d)).
Ideally I'd like them to be able to navigate via the keyboard arrows, moving up and down though the nested subexpressions, and hit enter when they come to the subexpression they want. However if its only possible to do this on mouse click, thats also acceptable.
The main issue that I'm having with this is the nesting component. I could easily make the entire expression selectable, but I don't know how to allow subexpressions to be selectable using SWING components. Based on my research Swing doesn't allow nesting of labels of text areas in the manner that I need so I'm looking for any alternatives.
Any help or suggestions would be much appreciated.
You could use a Highlighter and a DocumentListener on the read-only JTextField suggested by Joop in the comment above, following http://docs.oracle.com/javase/tutorial/uiswing/components/textfield.html in the section about JTextFieldDemo. That way you can highlight your (partial) string and listen to what (sub)string is selected, and compare it to the original string to check for matches.