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

How should i code this gui interface using border layout. Count Vowels Count Vow

ID: 3858330 • Letter: H

Question

How should i code this gui interface using border layout.

Count Vowels Count Vowels in Big Files! C:lUsersigrantdiDocumentsitextiRandomNovel.txt C:UsersigrantdiDocumentsitextiRandomText.txt C:lUsersigrantdiDocumentsltexti Sherlock Holmes.txt C:Usersigrantd Documentsitexticop1001.txt C:lUsersigrantd Documentsltextiweb sites.txt sersigrantd Documentsitexticop1001.txt has 70 vowels. Usersigrantd Documentsitextiweb sites.txt has 692 vowels. C:lUsersigrantdiDocumentsltextiRandomText.txt has 6,720 vowels sersigrantd DocumentsitextRandomNovel.txt has 737,376 vo sersigrantd Documentsltextrsherlock Holmes.txt has 1,933,14 Add Files Process Clear Help

Explanation / Answer

import java.awt.BorderLayout;

import java.awt.Container;

import java.awt.Dimension;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

public class CountVowels {

public static boolean RIGHT_TO_LEFT = false;

public static void addComponentsToPane(Container contentPane) {

// Use BorderLayout. Default empty constructor with no horizontal and

// vertical

// gaps

contentPane.setLayout(new BorderLayout(20, 20));

if (!(contentPane.getLayout() instanceof BorderLayout)) {

contentPane.add(new JLabel("Container doesn't use BorderLayout!"));

return;

}

if (RIGHT_TO_LEFT) {

contentPane.setComponentOrientation(java.awt.ComponentOrientation.RIGHT_TO_LEFT);

}

JButton jbnSampleButtons = new JButton("Button 1 (PAGE_START)");

contentPane.add(jbnSampleButtons, BorderLayout.PAGE_START);

jbnSampleButtons = new JButton("Process (CENTER)");

jbnSampleButtons.setPreferredSize(new Dimension(20, 100));

contentPane.add(jbnSampleButtons, BorderLayout.CENTER);

jbnSampleButtons = new JButton("Add Files (LINE_START)");

contentPane.add(jbnSampleButtons, BorderLayout.LINE_START);

jbnSampleButtons = new JButton("Help (LINE_START)");

contentPane.add(jbnSampleButtons, BorderLayout.BEFORE_LINE_BEGINS);

jbnSampleButtons = new JButton("Clear (LINE_END)");

contentPane.add(jbnSampleButtons, BorderLayout.LINE_END);

}

private static void createAndShowGUI() {

JFrame.setDefaultLookAndFeelDecorated(true);

JFrame frame = new JFrame("Count Vowels");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// Set up the content pane and add swing components to it

addComponentsToPane(frame.getContentPane());

frame.pack();

frame.setVisible(true);

}

public static void main(String[] args) {

javax.swing.SwingUtilities.invokeLater(new Runnable() {

public void run() {

createAndShowGUI();

}

});

}

}

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