-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9786d96
commit 190a6f9
Showing
1 changed file
with
18 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,43 @@ | ||
package org.http4k.intellij.step | ||
|
||
import com.intellij.ui.JBColor | ||
import com.intellij.ui.JBColor.GRAY | ||
import org.http4k.intellij.wizard.Option | ||
import java.awt.Component | ||
import java.awt.Dimension | ||
import java.awt.Font | ||
import javax.swing.BorderFactory | ||
import java.awt.Component.LEFT_ALIGNMENT | ||
import java.awt.Font.BOLD | ||
import javax.swing.BorderFactory.createCompoundBorder | ||
import javax.swing.BorderFactory.createEmptyBorder | ||
import javax.swing.BorderFactory.createLineBorder | ||
import javax.swing.Box | ||
import javax.swing.BoxLayout | ||
import javax.swing.BoxLayout.X_AXIS | ||
import javax.swing.BoxLayout.Y_AXIS | ||
import javax.swing.JComponent | ||
import javax.swing.JLabel | ||
import javax.swing.JPanel | ||
import javax.swing.JTextArea | ||
|
||
fun OptionBox(button: JComponent, option: Option) = JPanel().apply { | ||
layout = BoxLayout(this, BoxLayout.Y_AXIS) | ||
maximumSize = Dimension(150, 150) | ||
preferredSize = Dimension(150, 150) | ||
layout = BoxLayout(this, Y_AXIS) | ||
|
||
border = BorderFactory.createCompoundBorder( | ||
BorderFactory.createLineBorder(JBColor.GRAY), | ||
BorderFactory.createEmptyBorder(10, 10, 10, 10) // 10px padding on all sides | ||
) | ||
border = createCompoundBorder(createLineBorder(GRAY), createEmptyBorder(5, 5, 5, 5)) | ||
|
||
// Create a panel to hold the button and label in a horizontal row | ||
val buttonWithLabel = JPanel().apply { | ||
layout = BoxLayout(this, BoxLayout.X_AXIS) // Horizontal layout | ||
isOpaque = false // Make it blend with the background | ||
add(JPanel().apply { | ||
layout = BoxLayout(this, X_AXIS) | ||
isOpaque = false | ||
|
||
add(button) | ||
add(Box.createHorizontalStrut(5)) // Small space between button and label | ||
add(Box.createHorizontalStrut(5)) | ||
add(JLabel(option.label).apply { | ||
font = font.deriveFont(Font.BOLD) | ||
font = font.deriveFont(BOLD) | ||
}) | ||
} | ||
|
||
add(buttonWithLabel) // Add the button and label panel | ||
add(Box.createVerticalStrut(5)) // Vertical space between rows | ||
}) | ||
add(Box.createVerticalStrut(5)) | ||
|
||
add(JTextArea(option.description).apply { | ||
lineWrap = true | ||
wrapStyleWord = true | ||
isEditable = false | ||
isOpaque = false | ||
border = null | ||
alignmentX = Component.LEFT_ALIGNMENT | ||
background = this@apply.background | ||
alignmentX = LEFT_ALIGNMENT | ||
}) | ||
} |