GUI/Maximum window dimensions: Difference between revisions
Content added Content deleted
mNo edit summary |
(Added Kotlin) |
||
Line 408: | Line 408: | ||
Insets: java.awt.Insets[top=0,left=0,bottom=30,right=0] |
Insets: java.awt.Insets[top=0,left=0,bottom=30,right=0] |
||
Max available: java.awt.Dimension[width=1920,height=1050]</pre> |
Max available: java.awt.Dimension[width=1920,height=1050]</pre> |
||
=={{header|Kotlin}}== |
|||
{{trans|Java}} |
|||
<lang scala>// version 1.0.6 |
|||
import java.awt.* |
|||
import javax.swing.JFrame |
|||
class Test : JFrame() { |
|||
init { |
|||
val r = Regex("""\[.*\]""") |
|||
val toolkit = Toolkit.getDefaultToolkit() |
|||
val screenSize = toolkit.screenSize |
|||
println("Physical screen size : ${formatOutput(screenSize, r)}") |
|||
val insets = toolkit.getScreenInsets(graphicsConfiguration) |
|||
println("Insets : ${formatOutput(insets, r)}") |
|||
screenSize.width -= (insets.left + insets.right); |
|||
screenSize.height -= (insets.top + insets.bottom); |
|||
println("Max available : ${formatOutput(screenSize, r)}") |
|||
} |
|||
private fun formatOutput(output: Any, r: Regex) = r.find(output.toString())!!.value.replace(",", ", ") |
|||
} |
|||
fun main(args: Array<String>) { |
|||
Test() |
|||
}</lang> |
|||
Sample output: |
|||
{{out}} |
|||
<pre> |
|||
Physical screen size : [width=1366, height=768] |
|||
Insets : [top=0, left=0, bottom=40, right=0] |
|||
Max available : [width=1366, height=728] |
|||
</pre> |
|||
=={{header|Lingo}}== |
=={{header|Lingo}}== |