Results 1 to 13 of 13
- 08-05-2010, 07:38 AM #1
Member
- Join Date
- Aug 2010
- Posts
- 7
- Rep Power
- 0
Which Layout should use for Creating multiline fill in the blanks.
I am getting a string from database which has a question in the format given below:
void main(){/n int a,b;\n printf("___",a+b);\n }
And i have to show this question in format
void main()
{
int a,b;
printf("<here should be a text box>",a+b);
}
There can be more than one fill in the blanks in a row and more than one row can have fill in the blanks.blanks are such that we can drop the choice in the blanks.
Please help me out.
- 08-06-2010, 01:09 AM #2
... huh?
is that to say, you have this kind of encoding to mean "____" is to be rendered when printed as a text field. ?
what if you encoded the question string stored in the database using some kind of custom HTML or XML, ? that should allow for arbitrary complex input form construction.
void main(){<br/>int a,b;\n printf("<textfield/>",a+b);<br/><select/><textfield/>}
and so on ?
- 08-06-2010, 02:10 AM #3
Hard to understand what you are asking.
For the text use Labels
For the input area use a TextField
The text in the labels can span several lines.
The textfield should be bottom aligned with the label.
How about a GridBagLayout?
- 08-06-2010, 06:15 AM #4
Member
- Join Date
- Aug 2010
- Posts
- 7
- Rep Power
- 0
how to use html text box for dropping text from java component.
Can we fire any event on dropping text on the html text field ?
- 08-06-2010, 02:01 PM #5
Is this an html question or a java programming question?dropping text on the html text field
How do you have an html text field in a java program?
- 08-06-2010, 03:18 PM #6
Member
- Join Date
- Aug 2010
- Posts
- 7
- Rep Power
- 0
This is Java Question
This is the java program , in which question is stored into html format which can be displayed on editor pane.what if you encoded the question string stored in the database using some kind of custom HTML or XML, ? that should allow for arbitrary complex input form construction.
void main(){<br/>int a,b;\n printf("<textfield/>",a+b);<br/><select/><textfield/>}
now here the question is this if we have text fields in Editor pane can we put any listener so that if we drop answer into that it can fire any event.
- 08-06-2010, 03:43 PM #7
Never worked with html in an Editor pane.
Do you have a small simple program that demonstrates the problem?
- 08-06-2010, 04:10 PM #8
Member
- Join Date
- Aug 2010
- Posts
- 7
- Rep Power
- 0
Editor pane with html text
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.IOException;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class DemoEditorPane extends JFrame{
private JEditorPane ep;
private String ques;
private JPanel top,bottom;
public DemoEditorPane() throws IOException {
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
setSize(d);
top = new JPanel(new BorderLayout());
bottom = new JPanel();
bottom.setLayout(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ques= "<html><body>void main()<br>{<br>int a=10,b=20;<br>printf(\"<input type=text name='1' size=10>\",a+b;<br>}<br></body></html>";
ep = new JEditorPane();
ep.setContentType("text/html");
ep.setEditable(false);
ep.setText(ques);
top.add(ep);
JLabel lblc1 = new JLabel("%d");
lblc1.setBounds(10, 10, 100, 30);
bottom.add(lblc1);
JLabel lblc2 = new JLabel("%f");
lblc2.setBounds(10, 40, 100, 30);
bottom.add(lblc2);
JLabel lblc3 = new JLabel("%c");
lblc3.setBounds(10, 70, 100, 30);
bottom.add(lblc3);
add(top,BorderLayout.NORTH);
add(bottom,BorderLayout.CENTER);
setVisible(true);
}
public static void main(String ar[]) throws IOException{
new DemoEditorPane();
}
}
Here in the above program upper panel consists of question and lower panel consists of choices and i want that user can drop the choice in the text in the above question panel.
i can put transfer handler in the choice label , but how come the text box came to know that string is dropped on them.
- 08-06-2010, 04:46 PM #9
Don't know about dropping.
Have you typed something into the input field and pressed Enter? I get a NPE.
The stack trace shows a class: FormView that should lead you to how to get at the data entered.
- 08-06-2010, 05:06 PM #10
Member
- Join Date
- Aug 2010
- Posts
- 7
- Rep Power
- 0
editor pane is setEditable(false)
- 08-06-2010, 05:17 PM #11
Member
- Join Date
- Aug 2010
- Posts
- 7
- Rep Power
- 0
Ok.Html text is the one way to solve this problem.But as you suggest grid bag layout.
But as i said question is coming from the database and there can be more than one text box required on a single line and there can be more than one line of question.
So is it not complicated to use grid bag layout.
- 08-06-2010, 05:48 PM #12
Why do you need to actually move the answer to the empty slot in the display?
Wouldn't just selecting the answer/choice be enough?
Show the question with the place where the answer is to go,
and show a list of answers.
The user selects the answer by clicking on it. Drag and drop seems more than is needed.
Ok, I just saw there is more than one empty slot in a question. More thought required.
- 02-05-2011, 11:24 AM #13
Member
- Join Date
- Aug 2010
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
To get multiline tooltip
By diva_garg in forum New To JavaReplies: 8Last Post: 03-25-2011, 04:16 PM -
JTable multiline
By iceT18 in forum AWT / SwingReplies: 1Last Post: 02-11-2010, 01:02 AM -
How to write multiline String in a JLabel
By JavaBean in forum AWT / SwingReplies: 4Last Post: 12-14-2009, 05:09 AM -
Creating multiline item in JComboBox
By javabud in forum AWT / SwingReplies: 2Last Post: 07-17-2009, 03:50 PM -
Multiline Regex
By zriggle in forum New To JavaReplies: 1Last Post: 02-26-2009, 04:49 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks