Skip to content

Commit

Permalink
Change help dialog content to move to url
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcsgit committed Mar 20, 2023
1 parent c97666a commit 6f3ec92
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
73 changes: 73 additions & 0 deletions src/com/blogspot/kotlinstudy/lognote/HelpGotoDialog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.blogspot.kotlinstudy.lognote

import java.awt.BorderLayout
import java.awt.Desktop
import java.awt.Dimension
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import java.awt.event.MouseEvent
import java.awt.event.MouseListener
import java.net.URI
import javax.swing.*


class HelpGotoDialog(parent: JFrame) :JDialog(parent, Strings.HELP, true), ActionListener, MouseListener {
private var mHelpBtn: ColorButton
private var mCloseBtn : ColorButton
private val HELP_ADDRESS = "https://github.com/cdcsgit/lognote#readme"

init {
mCloseBtn = ColorButton(Strings.CLOSE)
mCloseBtn.addActionListener(this)

mHelpBtn = ColorButton(HELP_ADDRESS)
mHelpBtn.addMouseListener(this)

val panel = JPanel()
panel.layout = BorderLayout()

val helpPanel = JPanel()
helpPanel.preferredSize = Dimension(350, 40)
helpPanel.add(mHelpBtn)
panel.add(helpPanel, BorderLayout.CENTER)

val btnPanel = JPanel()
btnPanel.add(mCloseBtn)
panel.add(btnPanel, BorderLayout.SOUTH)

contentPane.add(panel)
pack()

Utils.installKeyStrokeEscClosing(this)
}

override fun actionPerformed(e: ActionEvent?) {
if (e?.source == mCloseBtn) {
dispose()
}
}

override fun mouseClicked(e: MouseEvent?) {
val desktop = if (Desktop.isDesktopSupported()) Desktop.getDesktop() else null
if ((desktop != null) && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(URI(HELP_ADDRESS))
return
} catch (e: Exception) {
e.printStackTrace()
}
}
}

override fun mousePressed(e: MouseEvent?) {
}

override fun mouseReleased(e: MouseEvent?) {
}

override fun mouseEntered(e: MouseEvent?) {
}

override fun mouseExited(e: MouseEvent?) {
}
}
2 changes: 1 addition & 1 deletion src/com/blogspot/kotlinstudy/lognote/MainUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,7 @@ class MainUI(title: String) : JFrame() {
aboutDialog.isVisible = true
}
mItemHelp -> {
val helpDialog = HelpDialog(this@MainUI)
val helpDialog = HelpGotoDialog(this@MainUI)
helpDialog.setLocationRelativeTo(this@MainUI)
helpDialog.isVisible = true
}
Expand Down

0 comments on commit 6f3ec92

Please sign in to comment.