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

  • SEARCH
  • Home
  • 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 966553
In Process

The Archive Base Latest Questions

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

import scala.swing._ import swing.event.{WindowClosing} import java.awt.Dimension object MenuBarTest { def main(args:Array[String]) { val frame

  • 0
import scala.swing._
import swing.event.{WindowClosing}
import java.awt.Dimension
object MenuBarTest {
  def main(args:Array[String]) {


    val frame = new Frame() {
      visible=true
      contents = new Panel() {
        preferredSize = new Dimension(600,400)
      }
      title = "Test"
      reactions += {
        case WindowClosing(e) => System.exit(0)
      }
      menuBar = new MenuBar {   
        contents += new Menu("A Menu") {      
          contents += new MenuItem("An item")      
          contents += new MenuItem(Action("Action item") { println(title) })       
          contents += new Separator        
          contents += new CheckMenuItem("Check me")
        }
      }
    }
  }
}

alt text http://grab.by/grabs/4a0ffda4603149a4680415447c684129.png

The instant I resize the window, the menu pops in.

alt text http://grab.by/grabs/cef34bf57327edf6d47f9a0e14902285.png

Any idea why this is and how I can prevent this from happening?

  • 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-16T02:10:31+00:00Added an answer on May 16, 2026 at 2:10 am

    Try changing the order of the statements. E.g. bringing visible = true to the end of the frame definition.

    Another thing would be to call the pack method after creating frame.

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

Sidebar

Related Questions

Java code: import javax.swing.Timer; class Main { public static void main(String args[]) { MyListener
import java.util.Scanner; public class CourseSplitter { public static void main(String args[]){ Scanner keyboard =
import org.joda.time.LocalDate; public class Test { public static void main(String[] args) { long time=System.currentTimeMillis();
import java.awt.*; import javax.swing.*; import javax.swing.GroupLayout; /** * @author Ene Ion */ public class
This can be done using a converter wrapper: import scala.collection.JavaConversions._ object ListConverter { def
This code gives compilation error: import scala.util.continuations._ object CTest { def loop: Nothing =
My Problem: error: object swing is not a member of package scala import scala.swing._
How to make that BMP will fill the JPanel? import java.awt.Dimension; import java.awt.Graphics; import
import java.io.*; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; public class ExplicitChannelRead { /** * @param args
Using scala, 2.8: import scala.collection.mutable import mutable.MultiMap val m = new mutable.HashMap[String, mutable.Set[String]] with

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.