#332: SwingUtils.kt
projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt Kotlin class, projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt 99 lines · 67 code · 24 comments · 8 blank
Purpose: Source file: setup/wizard/swing/SwingUtils.kt. SwingUtils.kt is part of the ProjectForge open-source project management application.
Source (first 100 lines)
/////////////////////////////////////////////////////////////////////////////
//
// Project ProjectForge Community Edition
// www.projectforge.org
//
// Copyright (C) 2001-2026 Micromata GmbH, Germany (www.micromata.com)
//
// ProjectForge is dual-licensed.
//
// This community edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published
// by the Free Software Foundation; version 3 of the License.
//
// This community edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
// Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, see http://www.gnu.org/licenses/.
//
/////////////////////////////////////////////////////////////////////////////
package org.projectforge.setup.wizard.swing
import org.projectforge.setup.wizard.Texts
import java.awt.FlowLayout
import java.awt.GridBagConstraints
import java.awt.Insets
import javax.swing.*
internal object SwingUtils {
private val log = org.slf4j.LoggerFactory.getLogger(SwingUtils::class.java)
fun constraints(x: Int, y: Int,
width: Int = 1,
height: Int = 1,
fill: Int = GridBagConstraints.NONE,
anchor: Int = GridBagConstraints.LINE_START,
weightx: Double = 0.0,
weighty: Double = 0.0,
insetTop: Int = 2,
insetLeft: Int = 2,
insetBottom: Int = 2,
insetRight: Int = 2
): GridBagConstraints {
val constraints = GridBagConstraints()
constraints.gridx = x
constraints.gridy = y
constraints.gridwidth = width
constraints.gridheight = height
constraints.fill = fill
constraints.anchor = anchor
constraints.weightx = weightx
constraints.weighty = weighty
constraints.insets = Insets(insetTop, insetLeft, insetBottom, insetRight)
return constraints
}
/* fun createButtonBar(context: SGUIContext, width: Int, vararg buttons: JButton): JPanel {
return createButtonBar(context,
JSeparator(SwingConstants.HORIZONTAL), //.setPreferredSize(TerminalSize(width, 1)),
*buttons)
}*/
fun createButtonBar(context: SwingGUIContext, showExitButton: Boolean = true, vararg buttons: JButton): JPanel {
val panel = JPanel(FlowLayout())
panel.add(JSeparator(SwingConstants.HORIZONTAL))
val buttonBar = JPanel()
if (showExitButton)
buttonBar.add(getExitButton(context))
for (component in buttons) {
buttonBar.add(component)
}
panel.add(buttonBar)
return panel
}
fun getExitButton(context: SwingGUIContext): JButton {
val exitButton = JButton(Texts.BUTTON_EXIT)
exitButton.addActionListener {
val options = arrayOf(Texts.BUTTON_CANCEL, Texts.BUTTON_EXIT)
if (JOptionPane.showOptionDialog(context.mainFrame,
Texts.EXIT_QUESTION,
Texts.EXIT_TITLE,
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]) == 1)
context.setupMain.exit()
}
return exitButton
}
fun convertToMultilineLabel(str: String): String {
return "<html>" + str.replace("\n", "<br>") + "</html>"
}
}
Git History
868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
5f7ef41b8 Copyright 2021 -> 2022
868d6abb7
2025 -> 2026868d6abb75cd191a892911ac8e45058932cf9074
diff --git a/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt b/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
index 176f7a566..dede7ba0d 100644
--- a/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
+++ b/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
@@ -3,7 +3,7 @@
// Project ProjectForge Community Edition
// www.projectforge.org
//
-// Copyright (C) 2001-2025 Micromata GmbH, Germany (www.micromata.com)
+// Copyright (C) 2001-2026 Micromata GmbH, Germany (www.micromata.com)
//
// ProjectForge is dual-licensed.
//
63081666f
Source file headers: 2024-> 2025.63081666f620fb87315f01b817e560e0b2f6a33a
diff --git a/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt b/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
index d6c138802..176f7a566 100644
--- a/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
+++ b/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
@@ -3,7 +3,7 @@
// Project ProjectForge Community Edition
// www.projectforge.org
//
-// Copyright (C) 2001-2024 Micromata GmbH, Germany (www.micromata.com)
+// Copyright (C) 2001-2025 Micromata GmbH, Germany (www.micromata.com)
//
// ProjectForge is dual-licensed.
//
b6092df09
Copyright 2023 -> 2024b6092df0927c4a3b161e888445f31dcab57493f2
diff --git a/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt b/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
index 63244d89e..d6c138802 100644
--- a/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
+++ b/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
@@ -3,7 +3,7 @@
// Project ProjectForge Community Edition
// www.projectforge.org
//
-// Copyright (C) 2001-2023 Micromata GmbH, Germany (www.micromata.com)
+// Copyright (C) 2001-2024 Micromata GmbH, Germany (www.micromata.com)
//
// ProjectForge is dual-licensed.
//
ab45d51fa
Copyright 2001-2022 -> 2001-2023.ab45d51fa419ede6174b31d69987f96d4b841ff9
diff --git a/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt b/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
index 619800f8d..63244d89e 100644
--- a/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
+++ b/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
@@ -3,7 +3,7 @@
// Project ProjectForge Community Edition
// www.projectforge.org
//
-// Copyright (C) 2001-2022 Micromata GmbH, Germany (www.micromata.com)
+// Copyright (C) 2001-2023 Micromata GmbH, Germany (www.micromata.com)
//
// ProjectForge is dual-licensed.
//
5f7ef41b8
Copyright 2021 -> 20225f7ef41b8cbbf29b1bff094f0c0b708dcaecb19e
diff --git a/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt b/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
index 5b71ff5a3..619800f8d 100644
--- a/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
+++ b/projectforge-application/src/main/kotlin/org/projectforge/setup/wizard/swing/SwingUtils.kt
@@ -3,7 +3,7 @@
// Project ProjectForge Community Edition
// www.projectforge.org
//
-// Copyright (C) 2001-2021 Micromata GmbH, Germany (www.micromata.com)
+// Copyright (C) 2001-2022 Micromata GmbH, Germany (www.micromata.com)
//
// ProjectForge is dual-licensed.
//