Question: Hello I need help with a java programming question. Write an application that extends JPanel and displays your name. Place boxes of different colors around

Hello I need help with a java programming question.

Write an application that extends JPanel and displays your name. Place boxes of different colors around your name at intervals of 10 20 30 40 pixels save as JBorderPanel.java

I also need to modify it to so when the user enters their name in a JTextField the name is displayed with borders at intervals of 10 20 30 40pixels save as JBorderPanel2.java

This is what I have to far. Please help

package jborderpanel; import java.awt.*; import static java.awt.Color.BLUE; import javax.swing.*;

public class JBorderPanel extends JPanel { // declare variables and components

Font font = new Font("Arial", Font.PLAIN, 20); String phrase = " some name"; int height = 300; int width = 300; int startX = 10;// come back int startY = 10; final int DISTANCE = 10; //pixels between boxes final int NUM_BOXES = 4;

public void paintComponent(Graphics gr) { super.paintComponent(gr); for(int x = 0; x < NUM_BOXES; ++x) { gr.drawRect(startX, startY , width, height); } } public static void main(String[] args) { //declare & display frame JFrame aFrame = new JFrame("Border Panels"); aFrame.add(new JBorderPanel()); aFrame.setSize(400, 400); aFrame.setVisible(true); aFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!