mirror of
https://gitlab.com/2009scape/09launcher.git
synced 2025-12-09 16:45:54 -07:00
add draggability for the window for patch notes
This commit is contained in:
parent
721fb7bd7a
commit
b649477898
1 changed files with 38 additions and 6 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import java.awt.Desktop
|
||||
import java.awt.Dimension
|
||||
import java.awt.Image
|
||||
import java.io.File
|
||||
import com.sun.java.accessibility.util.AWTEventMonitor
|
||||
import java.awt.*
|
||||
import java.awt.event.MouseAdapter
|
||||
import java.awt.event.MouseEvent
|
||||
import java.awt.event.MouseMotionAdapter
|
||||
import java.net.URI
|
||||
import javax.imageio.ImageIO
|
||||
import javax.swing.*
|
||||
|
|
@ -17,7 +18,7 @@ object MainWindow : JFrame("2009scape Launcher") {
|
|||
|
||||
init {
|
||||
defaultCloseOperation = EXIT_ON_CLOSE
|
||||
preferredSize = Dimension(1366,768)
|
||||
preferredSize = Dimension(800,500)
|
||||
size = Dimension(800,500)
|
||||
val tileBG = BackgroundPanel(ImageIO.read(javaClass.getResource("/tile.png")))
|
||||
contentPane = tileBG
|
||||
|
|
@ -32,10 +33,41 @@ object MainWindow : JFrame("2009scape Launcher") {
|
|||
setLocationRelativeTo(null)
|
||||
isUndecorated = true
|
||||
isVisible = true
|
||||
isEnabled = true
|
||||
pack()
|
||||
}
|
||||
|
||||
private fun constructTopBar(){
|
||||
val panel = BackgroundPanel(ImageIO.read(javaClass.getResource("/topBar.png")))
|
||||
val panel = object : BackgroundPanel(ImageIO.read(javaClass.getResource("/topBar.png"))){
|
||||
var initialClick: Point = Point()
|
||||
var parent = MainWindow
|
||||
init {
|
||||
addMouseListener(object : MouseAdapter() {
|
||||
override fun mousePressed(e: MouseEvent) {
|
||||
initialClick = e.point
|
||||
getComponentAt(initialClick)
|
||||
}
|
||||
})
|
||||
|
||||
addMouseMotionListener(object : MouseMotionAdapter() {
|
||||
override fun mouseDragged(e: MouseEvent) {
|
||||
|
||||
// get location of Window
|
||||
val thisX = parent.location.x
|
||||
val thisY = parent.location.y
|
||||
|
||||
// Determine how much the mouse moved since the initial click
|
||||
val xMoved: Int = e.getX() - initialClick.x
|
||||
val yMoved: Int = e.getY() - initialClick.y
|
||||
|
||||
// Move window to this position
|
||||
val X = thisX + xMoved
|
||||
val Y = thisY + yMoved
|
||||
parent.setLocation(X, Y)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
panel.placeAt(0,0,MainWindow.width, 40)
|
||||
addCloseButton(panel)
|
||||
addNewsButton(panel)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue