简体   繁体   中英

Textfield within a textfield

I have made a GUI calculator in net beans, this is what it looks like:

GUI计算器

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

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:

  1. a JLabel on the left
  2. a JTextField on the right.

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM