-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscriptSwing.js
More file actions
31 lines (27 loc) · 1.44 KB
/
scriptSwing.js
File metadata and controls
31 lines (27 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
print('Starting swing...')
// Import the Swing GUI components and a few other classes
importPackage(javax.swing);
importClass(javax.swing.border.EmptyBorder);
importClass(java.awt.event.ActionListener);
importClass(java.net.URL);
importClass(java.io.FileOutputStream);
importClass(java.lang.Thread);
// Create some GUI widgets
var frame = new JFrame("Rhino URL Fetcher"); // The application window
var urlfield = new JTextField(30); // URL entry field
var button = new JButton("Download"); // Button to start download
var filechooser = new JFileChooser(); // A file selection dialog
var row = Box.createHorizontalBox(); // A box for field and button
var col = Box.createVerticalBox(); // For the row & progress bars
var padding = new EmptyBorder(3,3,3,3); // Padding for rows
// Put them all together and display the GUI
row.add(urlfield); // Input field goes in the row
row.add(button); // Button goes in the row
col.add(row); // Row goes in the column
frame.add(col); // Column goes in the frame
row.setBorder(padding); // Add some padding to the row
frame.pack(); // Set to minimum size
frame.visible = true; // Make the window visible
while (true){
Thread.sleep(5000);
}