Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Is there away I can change these codes from Java to Python 3.6. Here are java co

ID: 3888940 • Letter: I

Question

Is there away I can change these codes from Java to Python 3.6. Here are java codes ,and I would like them to use as a Python

import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.net.URI; public class LinksGUI extends JFrame { private JPanel mainPanel; private JLabel urlText; public static void main(String[] args) { LinksGUI gui = new LinksGUI(); } LinksGUI() { setContentPane(mainPanel); pack(); setSize(new Dimension(350, 100)); this.setVisible(true); urlText.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { String url = urlText.getText(); try{ URI uri = new URI(url); if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(uri); } else { JOptionPane.showMessageDialog(LinksGUI.this, "Sorry, can't figure out your web browser"); } } catch (Exception ex) { System.out.println(ex); JOptionPane.showMessageDialog(LinksGUI.this, "That doesn't seem to be a valid URL."); } }

Explanation / Answer

Well I think there are some error on the java code itself. I have modified the code in Python it may give some faults do rectify as per needed which is also needed for Java code as well

----------------------------------------

from built-in module import*

class LinksGUI(JFrame):

__JPanel.mainPanel;

__JLabel.urlText;

main(String[] args):

gui = LinksGUI()

def __LinksGUI__():

def setContentPane(mainPanel)

def pack()

def setSize(new Dimension(350, 100))

self.setVisible(true)

urlText.addMouseListener(MouseListener():

@Override

def mouseClicked(MouseEvent.e):

url = urlText.getText()

try:

uri = URI(url)

if (Desktop.isDesktopSupported()):

Desktop.getDesktop().browse(uri)

else:

def JOptionPane.showMessageDialog(self.LinksGUI, "Sorry, can't figure out your web browser")

except IOError:

print("Error: can't find file or read data");

def JOptionPane.showMessageDialog(LinksGUI.this, "That doesn't seem to be a valid URL.")

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote