Swing/AWT/SWT :: Create A Basic Graphical User Interface For Sequence Translation
Mar 3, 2015
I am trying to create a basic graphical user interface for sequence translation (including a JTextField for the description of a sequence and status of function button pressed e.g. “simple” translation and input and output TextFields). This involves a number of different class files. I cannot get my user interface to do what I want and I think I have problems with my "actionPerformed" method. How the code should be linked together?
public void actionPerformed(ActionEvent event) {
try {
// Get the description, content and result
String d = tool.getDescription();
String input = tool.getInputText();
Stringr = translation.getResult();
I am making an app that would allow user to buy seat either by Price or Choice (Row and Column). I have Original code where it runs within JAVA IDE I am making same thing but rather in GUI now. I need putting my Buttons, textfield, and area in organize fashion.
I have not explain how these buttons will behave or act but right now putting them in order is priority then I will add action listeners to do the task we intend to do. A Wire Frame of the code looks like this :
I am new a creating GUIs and am not quite sure how to correctly make one. I have done the inheritance parts, and created two extra appliances: a washer and dryer. Now Creating the GUI ....
Here are the instructions to my project.
Introduction to GUIs (+ some inheritance)
For this assignment, you are going to create a user interface that interacts with the setters and getters of some classes that you will create.
First, create an abstract class called Appliance. This abstract class should have two attributes (dealing with household appliances) and two abstract methods called turnOn() and turnOff(). These methods should return void.
Then, create two subclasses of Appliance that represent household appliances (like a Refrigerator or Stove ((don't use those!))). These subclasses should have two attributes that are specific to the various appliance. Each subclass should implement the turnOn() and turnOff() methods. These methods should print to the command line some information about the appliance as it turns on and off.
Now, the fun part! Create a GUI interface!
Your window should have two panels: one for each appliance subclass. Each panel should have 4 textboxes (with appropriate labels) to receive/display information that correspond to the 4 attributes (2 from Appliance and 2 from the subclass) for each subclass.You also need 2 buttons on each panel: A Get button and a Set button.
When the Get button is pressed, the text boxes should be filled with the information from the instantiated object of the appropriate subclass. When the Set button is pressed, the object should then contain the information contained that the user has altered.
In your main method, you should create an object of each subclass, and prefill it with information (either using the constructor or the setters), then display your GUI. You should now be able to get and set the information for your objects from the GUI.
At least one of your attributes for each subclass should be numeric
Note that you will need to handle incorrectly formatted input (You can use exception handling to do this if you want to. Wrapper classes also will work)
If there is text in the boxes when the "Get" button is pressed, it should be overwritten by what is in the object. Remember that these two panels should both be on screen at the same time.
You don't need 2 different windows, one window: 2 panels.
I am new to programming so for loops are a little confusing to me still but basically what I am doing is making a small java rpg game and I want to add in a time element to it so your character gets things like promotions and such after a certain amount of time playing.
for (int x = months; x < 12; years++) { for (int y = weeks; y < 4; months++) { for (int z = days; z < 7; weeks++) { for (int j = hours; j < 24; days++) { for (int k = minutes; k < 60; hours++) { } } } } }
That's what I have so far but I am getting a logical error/ infinite loop when I run. I have added each unit of time as a static variable so there's no problem there.
I am a visual effects artist not a programmer but I wanna create a very basic translation software to improve english language in primary school students in my country. I cannot program at all except html and css but I am willing to do and learn whatever it takes to make this work. I don't know where to start from or what language to use. The structure of the program is to type an english word and then it must give out a translation of my local language and vice versa and I would like to add audio to the words.
I have a database containing products which are separated in categories and subcategories.I want to create a user interface that will allow the customer to select any category or subcategory and load the products in the main application window.My problem is that i dont like tree do you know any alternative of tree that i can use ?
What I'm trying to do is show a loginscreen. After logging in it should show another contentpane with actual content.
This is my main class:
public class Project extends JFrame { public static void main(String[] args) { JFrame frame = new Project (); JPanel paneel = new Paneel (); frame.setSize (800, 600);
[Code] ....
The compiler gives me an error when I try to refer to "frame". What I've tried to do is refer to frame by using Project.frame but it still gives me the same error. The compiler shows the message that it cannot find "frame" in class Project, but that's exactly where it is!
Is there a simple way to make this work? I've read about threads and loops but they don't seem the most basic solution. Maybe there's a way to get the current frame so I can use that?
basically I'm a good way through developing a Poker game which I've been developing just for fun(!?) and also to improve my skills, which it has done substantially. The logic involved with some of the hand comparisons and the evaluations of the winner is pretty complex.
Nonetheless, once I've finished the threaded timer to control the regulation of rising blind levels, and the betting mechanics for the Computer players I'll be looking to start creating the front end and this is where I'm a little confused.
Obviously for what I want, neither swing or AWT would be sufficient, so I guess the gap in my knowledge is how to integrate my back end code with a web front end. Is this possible? - What options exist for integration? just pure CSS / JS, or would Angular.js be viable? I'm looking to utilise some ready made images as graphics with maybe some minor animation effects.
I want to declare integers, while the program is running.
I run the program and then I give it via System.in.println an integer and repeat this as long as I want. I want the program to give those integers a name of a certain type for, for example a(i) or a[i], dunno, (it should be handy) and then a(i) represents the the i'th integer I gave the program. My idea is then that I can use those elements by their name just like, if I had declared them in the first place. For example add two integers together. For example I defined a method add+, which waits for 2 integer and then adds them. For example I write:
add
a(2)
a(47)
(then I would get here the result.)
However I don't know, how to let the program count the number of inputs or how to let it declare and use variables.
I want to declare integers, while the program is running.
I run the program and then I give it via System.in.println an integer and repeat this as long as I want. I want the program to give those integers a name of a certain type for, for example a(i) or a[i], dunno, (it should be handy) and then a(i) represents the the i'th integer I gave the program. My idea is then that I can use those elements by their name just like, if I had declared them in the first place. For example add two integers together. For example I defined a method add+, which waits for 2 integer and then adds them. For example I write:
add a(2) a(47)
(then I would get here the result.)
I don't think implementing the add function is difficult. However I don't know, how to let the program count the number of inputs or how to let it declare and use variables.
You have to create a very basic hangman type of game. Open Notepad and create a list of at least ten words in a text file. Save the file as a .txt file and use it to read words for the game. In this game you do not have to show pictures but you do need to keep track of the amount of times that the user has guessed wrong. When the game starts, show the amount of characters in the word represented as dashes and ask the user to type in a letter. if the user guesses correctly show the word again with the correct letter filled in the correct positions(s) and if the user correctly guessed the word, show a message. If the user guesses wrong, keep track of the body parts that needs to be reduced with every wrong guess and inform the user as well, also show a message.
I'm struggling with reading the file, showing the amount of parts left and asking the user to play again. Here is the code:
package hangman;
/** * * @author */ import java.nio.*; import java.io.*; import java.util.*; public class HangMan {
So I have one set of If Else If statements. My program calculates just the first comboBox. It is retrieving all the values from the other comboBoxes but I do not understand where to place the other If statement structure so I can calculate the other values I have set for the other objects. I would not like to use a different class for each and I know I have my calculations done right below my current if statement. Could it be left there and where shall I place the other if statements so they get read by my arithmetic sequence?
public void actionPerformed(ActionEvent e) { Object source = e.getSource() ; int deckSiz = (int) Decks.getSelectedIndex() ; int wheelSiz = (int)Wheels.getSelectedIndex();
I know that we can create an inner class inside an interface but i want to know that why we'll create an inner class inside an interface. I mean what is the use of creating inner class inside an interface and what is the advantage of it.
I need to create and simulate an ATM interface for my computer programming class using scanner class, if else & switch statements. I've been working on this assignment all day and I'm still no closer to figuring out how to do it. I'm currently working in NetBeans to try and solve it. I have attached the pdf , what I need to do. This is what I have so far:
package bankatmifelse; //Gator Bank ATM Program import java.util.Scanner; public class BankATMIfElse {
I'm having some difficulty with my bank account project. I'm supposed to create a menu where the user can create a new account, withdraw, deposit, view their balance, and exit. There's issues with the account creation.
Here's my necessitated class below: BankAccount, TestBankAccount, SavingsAccount, CurrentAccount, and Bank
I certify that this assignment is my own work and that I have not copied in part or whole or otherwise plagiarized the work of other students and/or persons.
Now I am trying to run this jsp, it will be translated into servlet. When i checked the generated servlet I found both the above code snippet(scriplet and expression) came in to _jspService method. But in the internet and in many other book i found that scriplet and expression portions will come in the doGet/doPost method (which will be called from jspservice).
So any specific reason why in this case it went in to jspservice method (though I am getting desired output)? I am using tomcat 6.
I am making an expert system using Jess about animals. I wanted to make an interface using Swing and so I did. I have a problem using group layouts. The application works fine but at the end a exceptions is thrown:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: javax.swing.JLabel[,0,0,0x0,invalid,alignmentX=0.0, alignmentY=0.0,border=,flags=8388608,maximumSize=,minimumSize=, preferredSize=,defaultIcon=,disabledIcon=,horizontalAlignment=LEADING, horizontalTextPosition=TRAILING,iconTextGap=4,labelFor=, text=The animal is a cheetah.,verticalAlignment=CENTER, verticalTextPosition=CENTER] is not attached to a horizontal group
[Code] ....
The application ask the user some questions about the animal. When the expert system has enough information to know the animal it tells the name of the animal and shows a picture of it. The exception is thrown when the application has guessed the animal and shows the response.
The project is to develop the game Translate the Word .... It is asking user to translate a word proposed to and check if the input response is correct. At the end of the game score will be calculated and displayed.
Game Play :
1 - Ask the user to specify , through the console , its name and the number of words to offer . It is up to you to handle exceptions (eg number of words greater than the number you provided ) 2 - Recover user response ( the word translated ) and check whether to continue . (eg you want to continue (y / n)) after each proposal. 3 - compare the response of the user with that which is preset for the word in question . 4 - Show the score at the end ( or at the breakpoint ) . 5 - Save the file in a user name , the score , the number of questions and the start date and end of the game played .
Some notes to consider :
1 - The language (eg, English - French , English - Arabic , etc. . ): It is up to you to specify the language adopted in the game and inform the user of your choice. 2 - The word bank to offer : It is up to you to develop the appropriate means to get the words to propose to the user. That said , the words and their translations can be retrieved :
a. a TXT file b . an XML file . ( Tutorials DOM and SAX ) c . CSV file ( OpenCSV Tutorial ) d. a database ( Tutorial Access) e . through APIs (eg Wordnet and google translate etc . ) . f . a combination of the previous options a, bc , d and / or e . (eg words stored in a txt file and answers retrieved from the api google translate) g . etc. .
Examples of files and databases are attached to the project statement . You will need to add one or more external libraries to your project. Click here for details on adding external libraries to Netbeans .
3 - A user will be associated with the question score if he can translate the word correctly. The score for each question can be calculated based on the number of words / questions to be proposed .
Development : In this project you will need at least a class called Question to encapsulate the word and its translations and provide all necessary methods to manipulate the object type Question.
An interface called IParser to make extensible project. Any class that implements IParser is a parser file (XML , TXT , CSV , etc.). / Database. In your project there will be a single class that implements IParser and will be used to retrieve words and their translations.
Add the ability to store the questions and answers of the user on the hard disk. Make the class Serializable Question
I am trying to grab a graphical object from an arraylist, and reposition its coordinates on a Jframe when adding it. My program of course deals with strings, and once it sees specific words in my console, some method is called that adds, removes, or otherwises modifies certain objects on screen.
Here I want to say something like move(object[1],xpos,ypos) which will move a certain object from a specified point in the array, and move it to new x and y positions on the JFrame. I use a different class that extends a graphics program, so when I say add(something,x,y) it draws the object onscreen where I want it. These are some relevant, though incomplete, methods that should move an object already painted on screen:
Console class
Java Code:
public void doMoveCommand(String cmd, String arg, String xpos, String ypos) { int x = Integer.parseInt(xpos); int y = Integer.parseInt(ypos); if (cmd.equals("posMake") && arg.equals("star")) { box.moveStar(box.historyG.get(1), x, y); //historyG is an arraylist of GPolygons freeCommand();
[Code] ....
When I say makepos(whatever) I am getting a arraylist out of bounds exception. How I might be able to accomplish moving objects already on screen?
So I have an array of objects, each with their own position, I tried switch the references in the array of two objects, then repainted (immediately), but the two objects aren't switching positions on screen...does this even work?
I am trying to clear all graphical objects of a certain type(all trees in particular). I have never had any issues doing so, and this method normally works well along with these variables:
Java Code:
public static ArrayList<GRect> historyT; public static ArrayList<GOval> historyL; public static GRect trunk; public static GOval leave; public void deleteTrees() { //clears all tree trunks and leaves
[Code]...
That is this normally worked until I started added more trees to the screen after they had all been erased. What happens is that it won't clear all of them unless the max has been reached, that is 6. It will remove all trees up till the last one if the max has not been reached. In other words here is my screen before the clear all if the max has not been reached(* is a tree, _ is erased): ****
Here is it after: _ _ _ _ *
So my question is, is why aren't all the trees deleted? Why does it leave one left behind?
I'm writing a graphical program with several Label objects. One of them is supposed to constantly change color. I tried to do it with while loop like this:
while (true) {label1.setColor(Color.blue); pause (80); label1.setColor(Color.red); pause (80);}
However, the rest of the code (after the loop) is never reached because the loop never ends. Is it possible to use infinite loop like this? And, is there any other way to handle permanent processes that are supposed to run as long as the program is running (like, in this case, blinking Label)?
I basically need to allow the user to add or remove toppings on the pizza once it is created. I am new to code (steps included). We are supposed to use enums and sets.
package pizza; public class Pizza { // Declare enums public enum Size{ SMALL, MEDIUM, LARGE, JUMBO
[code]....
I started this this is what I have currently I have an error here:
private Set<Topping> setOfToppings = new EnumSet<Topping>(Topping.class);
I am sure it is because I haven't set it up correctly.
Okay, so I know how to get user input and create a variable from the input, create a basic addition sum etc...
So I have this code:
package calc; import java.util.Scanner; class calc{ private static final double add = 0; private static final double subtract = 0; public static void main(String args[]){
[Code] .....
I'm basically trying to make it so that when the user enters tnum, tnum2, tnum3 and tnum4, their answer turns to the variable which has to be either true or false to make the boolean work. I don't know really how to do this. I want to make it so that if they enter yes, then that makes the boolean true and the numbers will multiply and create the answer variable. If they enter no then the boolean is false and it moves onto the next if statement. How can I do this?