Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7564195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:51:10+00:00 2026-05-30T13:51:10+00:00

private void KeyAction(java.awt.event.KeyEvent evt) { if (evt.getKeyCode() == 91) { int pos = txt.getCaretPosition();

  • 0
private void KeyAction(java.awt.event.KeyEvent evt) {                           
    if (evt.getKeyCode() == 91) {
        int pos = txt.getCaretPosition(); 
        txt.insert("}",pos);
    }      
}   

The function is currently showing But why it’s showing }{, but I’m expecting the output to be {}. How can I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:51:11+00:00Added an answer on May 30, 2026 at 1:51 pm

    How about:

    txt.insert("}", pos + 1);
    

    Pos is the position of the current character. Inserting at pos puts the inserted item in front of the current character. For your code, the output you see is the expected result. Try inserting after the current character.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) { //cant capture my TAB? System.out.print(evt.getKeyChar()); } What is the
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { int count = jSlider1.getValue(); int delay = jSlider2.getValue(); int
private void mostrarDiapositiva(Vector<Diapositiva> d, int pos) { if ( pos >= d.size() ) {
private void save(Rectangle src, Rectangle dest, string fName, int width, int height, Bitmap file)
private void dateTimePicker1_ValueChanged(object sender, Series myseries, int multiplier, EventArgs e) { if (datelimitsset ==
private void BindDataList() { int userId = Convert.ToInt32(ProfileInfo.GetUserID()); DataList1.DataSource = CatalogAccess.GetAddressByUserID(userId); DataList1.DataBind(); foreach (DataListItem
private void btnMiles_Click(object sender, EventArgs e) { try { int milesless200 = int.Parse(txtMiles.Text); int
private void btnStart_Click(object sender, EventArgs e) { Random random = new Random(); int randomNumber
private void sessionText() { try { System.IO.TextReader r = new System.IO.StreamReader(saved.txt); this.textBox1.Text = r.ReadLine();
private void DoSomeWork() { ManualResetEvent[] waitEvents = new ManualResetEvent[rowCount]; int i = 0; foreach

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.