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
Solved

TitleBorder error...

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

Author Closing Comment

by:Mike Eghtebas
ID: 36836642
Thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

837 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