Solved

TitleBorder error...

Posted on 2011-09-29
5
223 Views
Last Modified: 2012-05-12
Lines 23 and 45, TitleBorder is underlined in red.

Question: How can I correct this?

Thank you.
import java.awt.*;
import javax.swing.*;
//import javax.swing.JLabel;
import javax.swing.border.*;

public class TestSwingCommonFeatures extends JFrame{
    
    public TestSwingCommonFeatures() {
        JPanel p1=new JPanel(new FlowLayout(FlowLayout.LEFT,2,2));
        
        JButton jbtLeft=new JButton("Left");
        JButton jbtCenter=new JButton("Center");
        JButton jbtRight=new JButton("Right");
        
        jbtLeft.setBackground(Color.WHITE);
        jbtCenter.setBackground(Color.GREEN);
        jbtRight.setToolTipText("This is the right Button");
        
        p1.add(jbtLeft);
        p1.add(jbtCenter);
        p1.add(jbtRight);
        
        p1.setBorder(new TitleBorder("Three Buttons"));
        
        Font largeFont=new Font("TimesRoman",Font.BOLD,20);
        Border lineBorder=new LineBorder(Color.BLACK);
        
        JPanel p2=new JPanel(new GridLayout(1,2,5,5));
        
        JLabel jlbRed=new JLabel("Red");
        JLabel jlbOrange=new JLabel("Orange");
        
        jlbRed.setForeground(Color.RED);
        jlbOrange.setForeground(Color.ORANGE);
        
        jlbRed.setFont(largeFont);
        jlbOrange.setFont(largeFont);
        
        jlbRed.setBorder(lineBorder);
        jlbOrange.setBorder(lineBorder);
        
        p2.add(jlbRed);
        p2.add(jlbOrange);
        
        p2.setBorder(new TitleBorder("Two Labels"));
        
        setLayout(new GridLayout(2,1,5,5));
        add(p1);
        add(p2);
    }
    
    public static void main(String[] args){
        JFrame frame =new TestSwingCommonFeatures();
        frame.setTitle("TestSwingCommonFeatures");
        frame.setSize(300,150);
        frame.setLocationRelativeTo(frame);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}

Open in new window

0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36831846
it should be TitledBorder  there is "d" after e
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36832051
p2.setBorder(new TitledBorder("Two Labels"));  - this is how it works
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36832577
0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 36833733
0
 
LVL 34

Author Closing Comment

by:Mike Eghtebas
ID: 36836642
Thank you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
login form jsp example 2 67
sql import cannot be resolved jsp 3 110
Notify sent to other threads in Java 9 52
hashmap order 17 58
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Suggested Courses

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question