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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started