Solved

TitleBorder error...

Posted on 2011-09-29
5
219 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

708 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

16 Experts available now in Live!

Get 1:1 Help Now