Solved

TitleBorder error...

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

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 contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

728 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