Created
July 3, 2014 19:01
-
-
Save DV8FromTheWorld/8e60f49272bd724dce09 to your computer and use it in GitHub Desktop.
initVisualComponents : Imgur Uploader Java :
This file contains hidden or 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
| /** | |
| * Initializes all visual components of the GUI and adds them to the GUI. | |
| * Also sets the GUI's settings. | |
| */ | |
| private void initVisualComponents() | |
| { | |
| this.setTitle("Imgur Uploader"); | |
| this.setSize(SIZE_GUI_X, SIZE_GUI_Y); | |
| this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); | |
| this.setResizable(false); | |
| this.addWindowListener(this); | |
| panel = new JPanel(); | |
| panel.setLayout(null); | |
| btnUpload = new JButton(); | |
| btnUpload.setText("Upload"); | |
| btnUpload.setFont(FONT); | |
| btnUpload.setMargin(MARGIN); | |
| btnUpload.setLocation(93, 39); | |
| btnUpload.setSize(104, 38); | |
| btnUpload.addActionListener(this); | |
| btnPreview = new JButton(); | |
| btnPreview.setText("Preview"); | |
| btnPreview.setFont(FONT); | |
| btnPreview.setMargin(MARGIN); | |
| btnPreview.setLocation(110, 15); | |
| btnPreview.setSize(70, BUTTON_HEIGHT); | |
| btnPreview.addActionListener(this); | |
| btnCustomCapture = new JButton(); | |
| btnCustomCapture.setText("Custom Screen Capture"); | |
| btnCustomCapture.setFont(FONT); | |
| btnCustomCapture.setMargin(MARGIN); | |
| btnCustomCapture.setLocation(74, 130); | |
| btnCustomCapture.setSize(140, BUTTON_HEIGHT); | |
| btnCustomCapture.addActionListener(this); | |
| btnOpenBrowser = new JButton(); | |
| btnOpenBrowser.setText("Open in Browser"); | |
| btnOpenBrowser.setFont(FONT); | |
| btnOpenBrowser.setMargin(MARGIN); | |
| btnOpenBrowser.setLocation(15, 208); | |
| btnOpenBrowser.setSize(100, BUTTON_HEIGHT); | |
| btnOpenBrowser.addActionListener(this); | |
| btnOpenBrowser.setEnabled(false); | |
| btnCopyLink = new JButton(); | |
| btnCopyLink.setText("Copy Link"); | |
| btnCopyLink.setFont(FONT); | |
| btnCopyLink.setMargin(MARGIN); | |
| btnCopyLink.setLocation(152, 208); | |
| btnCopyLink.setSize(100, BUTTON_HEIGHT); | |
| btnCopyLink.addActionListener(this); | |
| btnCopyLink.setEnabled(false); | |
| lblLink = new JTextArea(); | |
| lblLink.setText("NO CURRENT LINK"); | |
| lblLink.setFont(FONT); | |
| lblLink.setLocation(88, 160); | |
| lblLink.setSize(190, 40); | |
| lblLink.setBackground(null); | |
| lblLink.setEditable(false); | |
| lblLink.setWrapStyleWord(true); | |
| lblLink.setLineWrap(true); | |
| lblTitle = new JLabel(); | |
| lblTitle.setText("Imgur Link:"); | |
| lblTitle.setFont(FONT); | |
| lblTitle.setLocation(15, 157); | |
| lblTitle.setSize(65, 20); | |
| lblUploadMessage = new JTextPane(); | |
| lblUploadMessage.setText(UPLOAD_MESSAGE); | |
| lblUploadMessage.setLocation(25, 80); | |
| lblUploadMessage.setSize(235, 35); | |
| lblUploadMessage.setBackground(null); | |
| lblUploadMessage.setEditable(false); | |
| setupTextCentering(lblUploadMessage); | |
| imageIcon = new ImageIcon(getClass().getResource("/assets/icon.png"), "Icon"); | |
| panel.add(btnUpload); | |
| panel.add(btnPreview); | |
| panel.add(btnCustomCapture); | |
| panel.add(btnOpenBrowser); | |
| panel.add(btnCopyLink); | |
| panel.add(lblLink); | |
| panel.add(lblTitle); | |
| panel.add(lblUploadMessage); | |
| this.add(panel); | |
| this.setIconImage(imageIcon.getImage()); | |
| itemShow = new MenuItem("Show"); | |
| itemShow.addActionListener(this); | |
| itemShow.setFont(FONT); | |
| itemUpload = new MenuItem("Upload"); | |
| itemUpload.addActionListener(this); | |
| itemUpload.setFont(FONT); | |
| itemExit = new MenuItem("Exit"); | |
| itemExit.addActionListener(this); | |
| itemExit.setFont(FONT); | |
| menu = new PopupMenu(); | |
| menu.add(itemShow); | |
| menu.add(itemUpload); | |
| menu.add(itemExit); | |
| trayIcon = new TrayIcon(imageIcon.getImage(), "Imgur Uploader", menu); | |
| trayIcon.setImageAutoSize(true); | |
| try | |
| { | |
| SystemTray.getSystemTray().add(trayIcon); | |
| } | |
| catch (AWTException e) | |
| { | |
| e.printStackTrace(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment