Hide frame instead of close when user click on close button of the window

I have an application which shows a window. Instead of closing window when user presses on "Close" button I want just to hide this window, how can I do this? Here is my code (it does not work, the app is closed on click): object UxMonitor { def main(args: Array[String]) { val frame = new MainScreen() frame.peer.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE) initTrayIcon(frame.peer) } .... class MainScreen extends MainFrame { private val HEADERS = Array[Object]("Security", "Last Price", "Amount", "Cost") private val quotes = new Quotes() private val tableModel = new DefaultTableModel() title = "UX Monitor" tableModel.setColumnIdentifiers(HEADERS) private val table = new Table { model = tableModel } contents = new ScrollPane { contents = table } quotes.setListener(onQuotesUpdated) quotes.startUpdating peer.addWindowListener(new WindowAdapter{ def windowClosing(e : WindowEvent){ self.setVisible(false) } }) pack
Try setting your default close operation to do_nothing_on_close but set it in your MainScreen class and leave your window listener as is.

以上就是Hide frame instead of close when user click on close button of the window的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准