Solved

TitleBorder error...

Posted on 2011-09-29
5
220 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
  • 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 33

Author Closing Comment

by:Mike Eghtebas
ID: 36836642
Thank you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Systems talking to each other 5 124
thymeleaf natural templating vs JSP 2 67
replace a word with other 1 40
table example 4 22
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now