Skip to content

Commit

Permalink
chore: Tweak appearance, title and allow full screen
Browse files Browse the repository at this point in the history
  • Loading branch information
bric3 committed May 19, 2024
1 parent 27b2b51 commit 03ccd2c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package io.github.bric3.fireplace

import com.formdev.flatlaf.extras.FlatInspector
import com.github.weisj.darklaf.platform.SystemInfo
import io.github.bric3.fireplace.jfr.ProfileContentPanel
import io.github.bric3.fireplace.jfr.support.JFRLoaderBinder
import io.github.bric3.fireplace.jfr.support.JfrFilesDropHandler
Expand Down Expand Up @@ -49,6 +50,8 @@ fun main(args: Array<String>) {
initUI(jfrBinder, paths)
}

private const val APP_NAME = "FirePlace"

private fun initUI(jfrBinder: JFRLoaderBinder, cliPaths: List<Path>) {
if (Utils.isFireplaceSwingDebug) {
if (System.getProperty("fireplace.swing.debug.thread.violation.checker") == "IJ") {
Expand All @@ -59,14 +62,20 @@ private fun initUI(jfrBinder: JFRLoaderBinder, cliPaths: List<Path>) {
EventDispatchThreadHangMonitor.initMonitoring()
}

if (SystemInfo.isMac) {
// This call has to happen before the Desktop toolkit is even initialized
// application name used in the screen menu bar
System.setProperty("apple.awt.application.name", APP_NAME)
}

with(Desktop.getDesktop()) {
if (isSupported(Desktop.Action.APP_ABOUT)) {
setAboutHandler {
JOptionPane.showMessageDialog(
null,
"""
<html>
<font size=+2><strong>Fireplace</strong> |</font> a JFR viewer
<font size=+2><strong>$APP_NAME</strong> |</font> a JFR viewer
<p>
Version: 0.0.1<br>
Expand Down Expand Up @@ -123,7 +132,7 @@ private fun initUI(jfrBinder: JFRLoaderBinder, cliPaths: List<Path>) {
hud.dnDTarget
)

JFrame("FirePlace").run {
JFrame(APP_NAME).run {
defaultCloseOperation = JFrame.EXIT_ON_CLOSE
size = Dimension(1400, 800)
contentPane.add(hud.component)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,7 @@ import java.awt.Rectangle
import java.awt.Taskbar
import java.awt.Toolkit
import java.awt.Window
import javax.swing.JButton
import javax.swing.JCheckBox
import javax.swing.JComponent
import javax.swing.JFrame
import javax.swing.JPanel
import javax.swing.JRootPane
import javax.swing.RootPaneContainer
import javax.swing.SwingUtilities
import javax.swing.UIManager
import javax.swing.*

@Suppress("unused")
internal object AppearanceControl {
Expand Down Expand Up @@ -85,12 +77,14 @@ internal object AppearanceControl {
// configure frame for transparency
if (SystemInfo.isMac) {
frame.rootPane.apply {
// allows to place swing components on the whole window
// Allow placing swing components on the whole window
putClientProperty("apple.awt.fullWindowContent", true)
// makes the title bar transparent
// Makes the title bar transparent
putClientProperty("apple.awt.transparentTitleBar", true)
// hide window title
// Hide window title
putClientProperty(DecorationsConstants.KEY_HIDE_TITLE, true)
// Allow to enter full screen when pressing Alt
putClientProperty("apple.awt.fullscreenable", true)
}
}
ExternalLafDecorator.instance().install()
Expand Down Expand Up @@ -148,7 +142,7 @@ internal object AppearanceControl {
System.setProperty(
"apple.laf.useScreenMenuBar",
"true"
) // moves menu bar from JFrame window to top of screen
) // moves menu bar from JFrame window to top of the screen
System.setProperty("apple.awt.application.name", title) // application name used in screen menu bar
// appearance of window title bars
// possible values:
Expand Down

0 comments on commit 03ccd2c

Please sign in to comment.