Reputation: 87
I have made a GUI calculator in net beans, this is what it looks like:
I was wondering if there is a way to insert a Text Field within a text field so I can display the operation that has been performed along with its result.
i want to display the operation performed in the top left corner of the same text field.
I have tried to drag and drop a text field over the main Text Field, it just slides the previous JTextField
to the right and inserts the second Text Field on the main panel. thanks in advance
Upvotes: 2
Views: 89
Reputation: 1828
if you r using netbeans is pretty simple first you have to make you JTextFiled(Operation one opaque) use the properties to do it so first you have to add a Jpanel which will contain the bouth Jtextfields then select the panel and set the layout property on NullLayout that will let you superpose your two JtextField then in the compenent viewer you have to make the operation textfield above the result textfield (to solve the z-order like in css) dont forget to make no border option for the operation textfield. sorry for my english if you wanna help tell me i will see how to do
Upvotes: 0
Reputation: 324197
i want to display the operation performed in the top left corner of the same text field(hence textfield within a text field question). is that possible?
Create a panel with two components:
You can get the Border
of the text field and use it as the Border of the panel so that it looks like the two components are one component.
Upvotes: 4
Reputation: 19471
I don't think you can do this with a textfield within a textfield. I would try to use a text control that is able to display both html text and multiple lines. Then you could add the two lines like
first line<br>secondline
wrapping the individual lines in tags gives you the ability to apply different fonts.
Upvotes: 0