JLabel Metal PLAF in 1.4

Hello,
in JRE 1.4 every JLabel now has a black foreground color in Metal PLAF.
I'm afraid that - together with their bold font - they are too heavy in their visual appearance.
What do you think?
Sven Meier

This is what I did under JDK1.4 environment. You should update titledborde color as well.
public class MyMainFrame extends JFrame {
// FIX: JDK1.4 uses a different default color for labels (=black).
// Change back to an old JDK1.2/JDK1.3 color value (blue).
static {
javax.swing.plaf.ColorUIResource colorNew;
colorNew = new javax.swing.plaf.ColorUIResource(102, 102, 153);
javax.swing.plaf.ColorUIResource colorOld;
colorOld = (javax.swing.plaf.ColorUIResource)UIManager.get("Label.foreground");
if (colorOld.equals(colorNew) == false) {
UIManager.put("Label.foreground", colorNew);
UIManager.put("TitledBorder.titleColor", colorNew);
public MyMainFrame() {
<...code continue here...>

Similar Messages

  • Plaf?

    Has anyone already come up with an XP-like plaf?
    The windows-plaf and metal-plaf are, to my eyes, very old looking. So, I'm curious about new plafs.
    btw. I know all about plafs like Compiere, ...
    What I'm realy interrested in, are the new (modern) plafs, like an XP-plaf or Netscape-plaf (very good). I don't even know if they exist...

    XP look and feel will be supported in 1.4.2, but you can download one that someone has made. You can find the link in this thread:
    http://forum.java.sun.com/thread.jsp?thread=350971&forum=57&message=1456605

  • Help with EventListeners

    ok can someone tell me what I can do to fix this. here is my code
    package game;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class GameFrame extends JFrame implements EventListener {
    public int plastic = 75;
    public int metal = 50;
    public int cloth = 30;
    public int money = 2000;
    public GameFrame() {
    super("Toy Tycoon!");
    setSize(600, 500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    FlowLayout flow = new FlowLayout(FlowLayout.CENTER);
    setLayout(flow);
    JPanel row1 = new JPanel();
    JLabel plasticLabel = new JLabel("Plastic($20)");
    row1.add(plasticLabel);
    JTextField plasticBuyAmt = new JTextField(5);
    row1.add(plasticBuyAmt);
    JButton buyPlastic = new JButton("Buy");
    buyPlastic.addActionListener(this);
    row1.add(buyPlastic);
    JLabel metalLabel = new JLabel("Metal($35)");
    row1.add(metalLabel);
    JTextField metalBuyAmt = new JTextField(5);
    row1.add(metalBuyAmt);
    JButton buyMetal = new JButton("Buy");
    buyMetal.addActionListener(this);
    row1.add(buyMetal);
    JLabel clothLabel = new JLabel("Cloth($10)");
    row1.add(clothLabel);
    JTextField clothBuyAmt = new JTextField(5);
    row1.add(clothBuyAmt);
    JButton buyCloth = new JButton("Buy");
    buyCloth.addActionListener(this);
    row1.add(buyCloth);
    add(row1);
    JPanel row2 = new JPanel();
    JLabel plasticAmt = new JLabel("Plastic: " + plastic + " ");
    row2.add(plasticAmt);
    JLabel metalAmt = new JLabel("Metal: " + metal + " ");
    row2.add(metalAmt);
    JLabel clothAmt = new JLabel("Cloth: " + cloth + " ");
    row2.add(clothAmt);
    add(row2);
    {color:#ff0000}public void actionPerformed(ActionEvent evt) {
    String cmd = evt.getActionCommand();{color}{color:#000000}(illegal start of expression){color}
    setVisible(true);
    public static void main(String[] args) {
    GameFrame game = new GameFrame();

    In the future, please use code tags to post your code.
    It appears that your actionPerformed method is defined inside of your constructor. Move it out to after the curly brace where setVisible(true) is called.

  • Default Button in YES_NO-JOptionPane

    Hello,
    in a YES_NO-JOptionPane the default button is YES. I would like to have it on NO. I managed to do this via getComponent. However, I am asking myself whether it has to be that complicated. Did anybody achieve this in a simpler way, e.g. in using setInitialSelectionValue or setInitialValue?
    Regards
    J�rg

    Hello Sai Pullabhotla,
    thank you for your code. I felt there had to be something simpler . Unfortunately the code works only with metal PLAF. But this is not a shortcoming of the code, but rather a Java bug, I suppose. I am going to send a bug report.
    Until the bug is fixed we could use the following code, which also allows to put the focus on the default button.
    String plaf="...";
      int defaultNOoptionPane(String message, String title)
      { // Displays a YES_NO optionPane with the No-button set as default.
        JOptionPane oPane = new JOptionPane(message, JOptionPane.QUESTION_MESSAGE,
                                   JOptionPane.YES_NO_OPTION);
        int i=1;
        if (plaf.equals("Motif")) i=2;
        JButton noButton = (JButton)((JPanel)oPane.getComponent(i)).getComponent(1);
        JDialog dialog = oPane.createDialog(this, title);
        dialog.getRootPane().setDefaultButton(noButton);
        noButton.requestFocus();
        dialog.show();
        Object selectedValue = oPane.getValue();
        if (selectedValue==null) return -1;
        return ((Integer)selectedValue).intValue();
      }Greetings
    J�rg

  • SWT/RCP loses Look and Feel

    My RCP application uses SWT widgets, and it loses its look and feel after executing through Webstart. Before, it had a nice 'clipse look when executed through Eclipse. When going through Webstart, it looks like default java (maybe worse). I tried setting the nativelib to the org.eclipse.swt_3.1.0.jar and when os is Linux I jar referenced the swtLinux*x86*.jar. The latter contains several *.so files referring to the architecture and window systems.
    Thanks for your suggestions/solutions,
    Ben

    The snippet I posted is obviously not "real" code from our product, but it does follow the same pattern-- Swing and AWT mixed and displayed through an SWT pane. Yes, it's pretty horrible. The SWT is a recent addition-- one that has complicated a lot of things, but we really can't get rid of it. The Swing and AWT are intertwined throughout the code, thousands of classes. Many of our group of developers have been forced to learn Java/Swing/Eclipse/SWT as we work, while those of us coming in with Java experience are overwhelmed by the sheer amount of code that needs to be re-written in order to follow current Java/Eclipse paradigms. We're in the process of moving everything to pure SWT, since that's the direction the higher-ups have decided upon, but we're doing things piecemeal (again, direction from higher-ups), turning sub-parts of the product into Eclipse plugins. That means that for the time being we need to make Swing, AWT, and SWT co-exist in relative harmony.
    So, everything is sort of a kludge, and the choice of technologies are dictated by people who don't have to do the actual coding. What's frustrating is that things were working fine with Java 1.5. We need to upgrade to Java 1.6 due to some other plugins that are being added to the product suite. Even when we take the code previously built against Java 1.5 and run it with Java 1.6, we see the unwanted look and feel behavior.
    We would really like to just find the source of the problem. Yes, the environment is kludgey, but something changed in either Java 1.6 or the Metal PLAF to cause the change in behavior.

  • Where did javax.swing.plaf.metal go after 1.4?

    Dear Users of the java.swing libraries,
    I've made a schoolproject in javax.swing and i am using the javax.swing.plaf.metal.MetalLookAndFeel as LookAndFeel.
    The Problem is: it seems sun has removed the Metal LookAndFeel in versions past 1.4 or something like that. I read this in the source DefaultmetalTheme.java file:
    * This class describes the default Metal Theme.
    * <p>
    * <strong>Warning:</strong>
    * Serialized objects of this class will not be compatible with
    * future Swing releases. The current serialization support is
    * appropriate for short term storage or RMI between applications running
    * the same version of Swing.  As of 1.4, support for long term storage
    * of all JavaBeans<sup><font size="-2">TM</font></sup>
    * has been added to the <code>java.beans</code> package.
    * Please see {@link java.beans.XMLEncoder}.
    * @version 1.25 01/23/03
    * @author Steve Wilson
    */Now i wonder, can i find this cool Metal style anywhere else? In like the java.beans that was mentioned in the code of DefaultmetalTheme.java.
    In my current situation my project is ruined and i would relly appriciate some feedback on this!
    Yours Truthfully,
    Alexander Thore

    They would only be where you put them.
    You should be importing them to your computer regularly as you would with any digital camera, most especially before any update.
    If you failed to do this, then they are likely gone.
    You can try a restore from backup.

  • How can I set a "Metal" LookAndFeel to a JFrame

    How can I set a "Metal" LookAndFeel to a JFrame?
    I�m using the JDK 5. In my pc, has that theme. I�m using Win2k

    try{
            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
            } catch (Exception e) {
                System.out.println("Error changing Look and Feel");
            }

  • Replacing a JLabel

    Hello
    I�ve got a problem with replacing a JLabel.
    I know it�s unusual to replace a JLabel, but I�ve got a class interpreting internal Error-Codes into �userfriendly messages�.
    And not only the Text is changing but also the background- and foreground-color. Sometimes even the font style.
    Short: it is like a Renderer for a single JLabel.
    My Class GuiController (that keeps the instance of my GUI) sets the new JLabel at the predefined place in my GUI.
    I don�t see it change but when I ask the Text of the Label (myLabel.getText( );) I get the new Text.
    There must be something simple I have not found yet. Or is it such a big no-no that I should solve it in a totally different way?
    Maybe it would be better to actually write a JLabel-Renderer (?)
    (But I would need 5 of them, because there are 5 Labels with different intepretations and Layouts...)
    here is a short demonstration program:
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.SwingUtilities;
    public class ReplaceJLabelTest {
      public ReplaceJLabelTest(){
        final TestGui l_oGui = new TestGui();
        try {
          Thread.sleep(1000);
        } catch (Exception e) {
          e.printStackTrace();
        SwingUtilities.invokeLater( new Runnable() {
          public void run() {
            l_oGui.setLabel(new JLabel("it is the new label"));
            l_oGui.getContentPane().validate();
            l_oGui.repaint();
            System.out.println(l_oGui.getLabel().getText()); // <-- returns "it is the new label" but I still see the old text.
      public static void main(String[] args) {
        new ReplaceJLabelTest();
      private class TestGui extends JFrame {
        JFrame m_oFrame = new JFrame();
        JLabel m_oLabel = new JLabel("this is the old label");
        public TestGui() {
          m_oFrame.getContentPane().add(m_oLabel);
          m_oFrame.pack();
          m_oFrame.setVisible(true);
        public void setLabel(JLabel p_strLabel) {
          m_oLabel = p_strLabel;
        public JLabel getLabel() {
          return m_oLabel;
    }I tried solutions given in older topics.
    Like http://forum.java.sun.com/thread.jspa?forumID=257&threadID=415307
    or
    l_oGui.pack();
    l_oGui.invalidate();
    l_oGui.repaint();
    l_oGui.getLabel().repaint();It did not really work for me...
    Thanks for taking the time to read this :)
    Greetings
    Sophia

    You can use the setUI function for installing a new UI.
    You can create a custom UI class by extending BasicLabelUI:
    http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/plaf/basic/BasicLabelUI.html
    Override protected void installDefaults(JLabel c) and set the foreground, background and font for c.

  • Look And Feel: Metal Themes

    Hello,
    I have two basic questions I can't find the answer to. I hope someone can help.
    From my understanding of Java 1.5 you now have 2 basic themes to them metal look and feel, they are "Ocean" (the default) and "Steel". Is this understanding correct?
    My second question is, I can switch between Look & Feels, ie. default to system, how do you switch between themes though? I want to use "Steel" but can't !
    Thanks,
    Alan

    How to Set the Lood and Feel:
    http://java.sun.com/docs/books/tutorial/uiswing/misc/p
    laf.htmlThat actually doesn't tell you how to do what he's asking.. at least not from what I saw.
    Here's how to set the metal theme in 1.5:
    import javax.swing.plaf.metal.*;
    public static final String STEEL_THEME_CLASS = "javax.swing.plaf.metal.DefaultMetalTheme";
    public static final String OCEAN_THEME_CLASS = "javax.swing.plaf.metal.OceanTheme";
    public void changeMetalTheme(String themeName) {
       try {
          MetalTheme theme = (MetalTheme)Class.forName(themeName).newInstance();
          MetalLookAndFeel.setCurrentTheme(theme);
       catch (Exception e) { e.printStackTrace(); }
    }Note that if you do this after you've created your GUI, you'll have to call SwingUtilities.updateComponentTreeUI() on all top-level windows.

  • Updating a JLabel Too Fast Crashes Program

    I have a recursive method that runs for 80 seconds (in a thread
    outside the GUI). The recursive method is probably being called
    20,000 times in this 80 seconds.
    I am calling myJlabel.setText("" + someVariable) every call to this recursive method.
    About half the time I run this program it crashes with the following error.
    Does anybody know why this is happening?
    I believe it has something to do with the speed of the calls because
    when I slow the method considerably (10x) I never get the error.
    I dont just want to wrap the call in try/catch without knowing the cause.
    Thanks!
    Exception in thread "Thread-2" java.lang.NullPointerException
            at javax.swing.text.View.setParent(View.java:322)
            at javax.swing.text.CompositeView.setParent(CompositeView.java:119)
            at javax.swing.text.View.setParent(View.java:325)
            at javax.swing.text.CompositeView.setParent(CompositeView.java:119)
            at javax.swing.text.FlowView.setParent(FlowView.java:272)
            at javax.swing.text.html.ParagraphView.setParent(ParagraphView.java:58)
            at javax.swing.text.View.setParent(View.java:325)
            at javax.swing.text.CompositeView.setParent(CompositeView.java:119)
            at javax.swing.text.html.BlockView.setParent(BlockView.java:55)
            at javax.swing.text.html.HTMLEditorKit$HTMLFactory$BodyBlockView.setParent(HTMLEditorKit.java:1277)
            at javax.swing.text.View.setParent(View.java:325)
            at javax.swing.text.CompositeView.setParent(CompositeView.java:119)
            at javax.swing.text.html.BlockView.setParent(BlockView.java:55)
            at javax.swing.plaf.basic.BasicHTML.updateRenderer(BasicHTML.java:194)
            at javax.swing.plaf.basic.BasicLabelUI.propertyChange(BasicLabelUI.java:409)
            at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
            at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
            at java.awt.Component.firePropertyChange(Component.java:7865)
            at javax.swing.JLabel.setText(JLabel.java:311)
            at LoadFrame.setInfo(LoadFrame.java:44)
            at LoadHandler.update(LoadHandler.java:67)
            at FilesLoader.recurseProcess(FilesLoader.java:69)
            at FilesLoader.recurseProcess(FilesLoader.java:93)
            at FilesLoader.run(FilesLoader.java:42)
            at java.lang.Thread.run(Thread.java:619)

    Are you updating the label in the Event Dispatch
    Thread (EDT)?I dont believe so. I spawn off a new thread to do the
    recursive file loading and that calls the JLabel.setText(...)
    The loading takes 80 secs and I can still use the GUI so I
    wouldnt think anything is happening in the EDT.
    Another bizarre glitch is that my JLabel has 4 lines of text like this:
    bold: plain
    bold: plain
    bold: plain
    And the bold and plain text are randomly glitching out.
    Sometimes a whole line will be bold, all not bold, all bold, plain
    ones bold, vice versa. Just random-ness.
    This is the code for setting the text:
    public void setText(String path, long folderCount, long fileCount, long ms){
    String time = (ms / 1000) + " seconds";
    infoLabel.setText("<html><b>Current Folder:</b> " + path +
    "<br><b>Folders:</b> " + folderCount +
    "<br><b>Files:</b> " + fileCount +
    "<br><b>Time:</b> " + time + "</html>");
    }

  • JLabel/html question

    how do you make a tab in html within a JLabel text.
    also how do you get rid of the bold that seems to be on every J label?

    Thanks Kel, I'm not using metal, but maybe that third line should do what I want?
    and Quack, I do whole heartedly agree with you, but this is something that I HAVE to finish by tomorrow. Considering I had quite a good bit more to do, and the way that I have done it seems to work just fine, I decided to leave it as is. If I finish with enough time, I will likely go back and implement that cardLayout like you suggested.
    Although I am curious, what is wrong specifically with how I have done it? (As for how the GUI components are changed)
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.*;
    import java.util.*;
    public class Holder extends JFrame implements ActionListener
        static Scanner scan;
        static int returnFileVal;
        static int index;
        static int totalEmployees;
        static double grossPayCalc;
        static double totalGross;
        static double totalFICA;
        static double totalFED;
        static double totalInsur;
        static double totalNet;
        static String data;
        static String totals;
        static File file;
        static ArrayList TermCode = new ArrayList();
        static ArrayList EmpID = new ArrayList();
        static ArrayList FName = new ArrayList();
        static ArrayList MName = new ArrayList();
        static ArrayList LName = new ArrayList();
        static ArrayList Suffix = new ArrayList();
        static ArrayList HourRT = new ArrayList();
        static ArrayList HourWK = new ArrayList();
        static ArrayList Dep = new ArrayList();
        static ArrayList Insur = new ArrayList();
        static ArrayList YTDGR = new ArrayList();
        static ArrayList YTDFICA = new ArrayList();
        static ArrayList YTDFED = new ArrayList();
        static ArrayList grossPay = new ArrayList();
        static ArrayList FICA = new ArrayList();
        static ArrayList FED = new ArrayList();
        static ArrayList netPay = new ArrayList();
        static ArrayList dataList = new ArrayList();
        static Holder f;
        static Container c;
        static JPanel homePanel = new JPanel();
        static JPanel firstRow = new JPanel();
        static JPanel secondRow = new JPanel();
        static JPanel thirdRow = new JPanel();
        static JPanel fourthRow = new JPanel();
        static JPanel fifthRow = new JPanel();
        static JPanel sixthRow = new JPanel();
        static JPanel seventhRow = new JPanel();
        static JPanel eighthRow = new JPanel();
        static JPanel ninthRow = new JPanel();
        static JLabel hoursWorkedLabel = new JLabel("Default hours worked:");
        static JTextField hoursWorkedField = new JTextField("40",2);
        static JButton processButton = new JButton ("Process payroll for all non-terminated employees");  
        static JButton closeButton = new JButton ("End Program");
        static JLabel chooseFileLabel = new JLabel("Select the payroll file");
        static JFileChooser fc = new JFileChooser();
        static JPanel filePanel = new JPanel();
        static JTextField fileChooseField = new JTextField(25);
        static JButton fileChooseButton = new JButton("Find");
        static JButton fileOKButton = new JButton("Process");
        static JButton fileBackButton = new JButton ("Back");
        static JPanel processPanel = new JPanel();
        static JLabel pleaseSelectLabel = new JLabel("Please select an option.");
        static JButton payrollJournalButton = new JButton("View the payroll journal");
        static JButton checkButton = new JButton ("View the checks");
        static JButton checkStubButton = new JButton ("View the check stubs");
        static JLabel payrollJournalTitle = new JLabel("<html><b><u>Payroll Journal</u></b></html>");
        static JButton payrollBack = new JButton("Back");
        static JPanel payrollPanel = new JPanel();
        static JList payrollList = new JList();
        static JLabel payrollEmployeeData = new JLabel();
        static JLabel payrollSubtitles = new JLabel ("EmpID\t\tName\t\tGross Pay\t\tFICA\t\tFED\t\tInsur\t\tNet Pay");
        static JLabel payrollTotals = new JLabel();
        static JScrollPane payrollScroll = new JScrollPane();
        public static void main(String[] args)
            f = new Holder();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setSize(450,300);
            f.setTitle("Payroll");
            f.setResizable(false);
            f.setLocation(200,200);
            f.setVisible(true);
            createHome();
        public Holder()
            c = getContentPane();
        public void actionPerformed(ActionEvent e)
        public static void createHome()
            firstRow.removeAll();
            secondRow.removeAll();
            thirdRow.removeAll();
            homePanel.removeAll();
            homePanel.setLayout(new GridLayout(3,1));
            FlowLayout rowSetup = new FlowLayout(FlowLayout.CENTER);
                firstRow.setLayout(rowSetup);
                secondRow.setLayout(rowSetup);
                thirdRow.setLayout(rowSetup);
            firstRow.add(hoursWorkedLabel);
            firstRow.add(hoursWorkedField);
            secondRow.add(processButton);
            thirdRow.add(closeButton);
            homePanel.add(firstRow);
            homePanel.add(secondRow);
            homePanel.add(thirdRow);
            closeButton.addActionListener(new endProgram());
            processButton.addActionListener(new processPayroll());
            c.remove(filePanel);
            c.add(homePanel);
            c.validate();
            c.repaint();
        public static void createPayroll()
            filePanel.removeAll();
            filePanel.setLayout(new GridLayout(3,1));
            FlowLayout rowSetup = new FlowLayout(FlowLayout.CENTER);
                firstRow.setLayout(rowSetup);
                secondRow.setLayout(rowSetup);
            firstRow.removeAll();
            secondRow.removeAll();
            thirdRow.removeAll();
            fileChooseButton.addActionListener(new fileChooser());
            fileBackButton.addActionListener(new fileBack());
            fileOKButton.addActionListener(new processFinal());
            firstRow.add(chooseFileLabel);
            secondRow.add(fileChooseField);
            secondRow.add(fileChooseButton);
            thirdRow.add(fileBackButton);
            thirdRow.add(fileOKButton);
            filePanel.add(firstRow);
            filePanel.add(secondRow);
            filePanel.add(thirdRow);
            c.remove(homePanel);
            c.add(filePanel);
            c.validate();
            c.repaint();
        public static void processFinal()
            try
                scan = new Scanner(new BufferedReader(new FileReader(file)));
            catch(IOException io)
                System.out.println("The file cannot be opened");
            scan.useDelimiter(",");
            index = 1;
            totalEmployees = 0;
           while (scan.hasNext())
               int type = index%13;
               switch (type)
                    case 1: TermCode.add(scan.next());
                            totalEmployees++;
                            break;
                    case 2: EmpID.add(new Integer(scan.next()));
                            break;
                    case 3: FName.add(scan.next());
                            break;
                    case 4: MName.add(scan.next());
                            break;
                    case 5: LName.add(scan.next());
                            break;
                    case 6: Suffix.add(scan.next());
                            break;
                    case 7: HourRT.add(new Double(scan.next()));
                            break;
                    case 8: HourWK.add(new Integer(scan.next()));
                            break;
                    case 9: Dep.add(new Integer(scan.next()));
                            break;
                    case 10:Insur.add(new Double(scan.next()));
                            break;
                    case 11:YTDGR.add(new Double(scan.next()));
                            break;
                    case 12:YTDFICA.add(new Double(scan.next()));
                            break;
                    case 0: YTDFED.add(new Double(scan.next()));
                            break;
                index++;
            for (index = 0; index < totalEmployees; index++)
                if ((Integer)HourWK.get(index) > 40)
                    grossPayCalc = (((Integer)HourWK.get(index)-40)*(Double)HourRT.get(index)*1.5);
                    grossPayCalc += (40*(Double)HourRT.get(index));
                else
                    grossPayCalc = ((Integer)HourWK.get(index)*(Double)HourRT.get(index));
                grossPay.add(grossPayCalc);
                FICA.add((Double)grossPay.get(index)*.0765);
                FED.add((290-65*(Integer)Dep.get(index))*.15);
                netPay.add((Double)grossPay.get(index)-((Double)FICA.get(index)+(Double)FED.get(index)+(Double)Insur.get(index)));
            firstRow.removeAll();
            secondRow.removeAll();
            thirdRow.removeAll();
            c.remove(filePanel);
            processPanel.setLayout(new GridLayout(4,1));
            FlowLayout rowSetup = new FlowLayout(FlowLayout.CENTER);
                firstRow.setLayout(rowSetup);
                secondRow.setLayout(rowSetup);
                thirdRow.setLayout(rowSetup);
                fourthRow.setLayout(rowSetup);
            firstRow.add(pleaseSelectLabel);
            secondRow.add(payrollJournalButton);
            thirdRow.add(checkButton);
            fourthRow.add(checkStubButton);
            payrollJournalButton.addActionListener(new viewJournal());
            processPanel.add(firstRow);
            processPanel.add(secondRow);
            processPanel.add(thirdRow);
            processPanel.add(fourthRow);
            c.add(processPanel);
            c.validate();
            c.repaint();
        public static void createFileChooser    ()
            returnFileVal = fc.showOpenDialog(filePanel);
            if (returnFileVal == JFileChooser.APPROVE_OPTION)
                file = fc.getSelectedFile();
            fileChooseField.setText(file.toString());
        public static void createJournal()
            f.setSize(700,500);
            firstRow.removeAll();
            secondRow.removeAll();
            thirdRow.removeAll();
            fourthRow.removeAll();
            c.remove(processPanel);
            payrollPanel.setLayout(new GridLayout(9,1));
            FlowLayout rowSetup = new FlowLayout(FlowLayout.CENTER);
                firstRow.setLayout(rowSetup);
                secondRow.setLayout(rowSetup);
                thirdRow.setLayout(rowSetup);
                fourthRow.setLayout(rowSetup);
                fifthRow.setLayout(rowSetup);
                sixthRow.setLayout(rowSetup);
                seventhRow.setLayout(rowSetup);
                eighthRow.setLayout(rowSetup);
                ninthRow.setLayout(rowSetup);
           data = new String("<html>");
           for (index = 0; index < totalEmployees; index++)
               data += (Integer)EmpID.get(index);
               data += "\t\t";
               data += ((String)FName.get(index) + " ");
               if (((String)MName.get(index)).equals(" ")==false)
                   data += ((String)MName.get(index) + ". ");
               data += ((String)LName.get(index) + " ");
               data += (String)Suffix.get(index);
               data += "\t\t";
               data += (Double)grossPay.get(index);
               data += "\t\t";
               data += (Double)FICA.get(index);
               data += "\t\t";
               data += (Double)FED.get(index);
               data += "\t\t";
               data += (Double)Insur.get(index);
               data += "\t\t";
               data += (Double)netPay.get(index);
               data += "</br>";
           data += "</html>";
           for (index = 0; index < totalEmployees; index++)
               totalGross += (Double)grossPay.get(index);
               totalFICA += (Double)FICA.get(index);
               totalFED += (Double)FED.get(index);
               totalInsur += (Double)Insur.get(index);
               totalNet += (Double)netPay.get(index);
           totals = new String ("Final Totals\t\t\t\t" + totalGross + "\t\t" + totalFICA + "\t\t" + totalFED + "\t\t" + totalInsur + "\t\t" + totalNet);
           payrollTotals.setText(totals);
           payrollEmployeeData.setText(data);
           firstRow.add(payrollBack);
           payrollBack.addActionListener(new processPayroll());
           secondRow.add(payrollJournalTitle);
           fourthRow.add(payrollSubtitles);
           fifthRow.add(payrollEmployeeData);
           eighthRow.add(payrollTotals);
           payrollPanel.add(firstRow);
           payrollPanel.add(secondRow);
           payrollPanel.add(thirdRow);
           payrollPanel.add(fourthRow);
           payrollPanel.add(fifthRow);
           payrollPanel.add(sixthRow);
           payrollPanel.add(seventhRow);
           payrollPanel.add(eighthRow);
           payrollPanel.add(ninthRow);
            c.add(payrollPanel);
            c.validate();
            c.repaint();
    class endProgram implements ActionListener
        public endProgram()
        public void actionPerformed(ActionEvent e)
            int answer = JOptionPane.showConfirmDialog(null,"Are you sure you want to end the program","f",JOptionPane.YES_NO_OPTION);
            if (answer == JOptionPane.YES_OPTION)
            System.exit(0);
    class processPayroll implements ActionListener
        public processPayroll()
        public void actionPerformed(ActionEvent e)
            Holder.createPayroll();
    class fileChooser implements ActionListener
        public fileChooser()
        public void actionPerformed(ActionEvent e)
            Holder.createFileChooser();
    class fileBack implements ActionListener
        public fileBack()
        public void actionPerformed(ActionEvent e)
            Holder.createHome();
    class processFinal implements ActionListener
        public processFinal()
        public void actionPerformed(ActionEvent e)
            Holder.processFinal();
    class viewJournal implements ActionListener
        public viewJournal()
        public void actionPerformed(ActionEvent e)
            Holder.createJournal();

  • Metal L&F bumps - how to get rid?

    Hi,
    Does anyone know how to make the metal bumps on the scroll bar drag area and splitpane divider go away? I'd prefer the plain and simple windows look - my app currently runs on HP-UX so I don't have the option to use the windows L&F. I can see it maybe something to do with overriding the setUI methods somewhere, however not having done it before I'd be very grateful of any pointers you can offer.
    Thanks, Dave

    Ok, I did this, and it works, but only on a specific instance.
    if ( _splitpane.getUI() instanceof javax.swing.plaf.metal.MetalSplitPaneUI )
       _splitpane.setUI( new javax.swing.plaf.basic.BasicSplitPaneUI() );
    }I'd like to make it work for all split panes instances, so I tried:
    UIManager.put( "SplitPaneUI", new javax.swing.plaf.basic.BasicSplitPaneUI() );with no effect, although with other statements of this form I can set default fonts for component classes.
    What am I missing?
    Best regards, Dave

  • How does one make a PLAF

    I understand that to make a custom LAF, all you need to do is extend one of the standard LAFs, but how do you describe how things are to look (and feel)? What I mean is if you want you text fields to have rounded corners, how do you go about having it show up in such a way?

    I don't know if this will help, but since you mentioned it will be an app mostly used on a Windows platform, I figured I'd mention this. By default swing uses the MetalLookAndFeel. But the sdk comes with other look and feels. There is one for Motif and Windows (the windows one only works on Windows platforms "for copyright reasons, it does not run on any other operating system" - Java Foundation Classes in a Nutshell). Now if you want a quick and dirty way to change the look and feel of everything to look like windows, try this.
    When you start your app, instead of using a bare java invocation, try
    java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel yourAppHere
    you also might want to poke around the javax/swing/plaf/metal subdirectory of the source shipped with the sdk. Metal is the default theme, as I mentioned, and all the functionality is in the classes contained in that directory. Hope this helped.
    - Anthony

  • Exceptions for JLabel with HTML format text.

    Hi,
    When the follow code been runing, and press the "Submit" button,
    the follow exceptions are thrown.
    How could I got a right result?
    I could not find a way to work out it, and need a export help me.
    Thanks and Best Regards.
    Xue
    JFrame f=new JFrame();
              JPanel p=new JPanel(new BorderLayout());
         JLabel label=new JLabel();
         label.setForeground(Color.blue);
         StringBuffer sb=new StringBuffer();
         sb.append("<html>");
         sb.append("<head>");
         sb.append("</head>");
         sb.append("<body>");
         sb.append("<p>A<font color=\"#FF0000\">BCD</font>E<font color=\"#FF0000\">F</font>G</p>");
         sb.append("<form method=\"POST\" action=\"http://openelec.vicp.net:8080/\">");     
         sb.append("<p>Text:<input type=\"text\" name=\"T1\" size=\"20\"><input type=\"submit\" value=\"Submit\" name=\"B1\"><input type=\"reset\" value=\"Cancel\" name=\"B2\"></p>");
         sb.append("</form>");
         sb.append("<table border=\"1\" width=\"100%\" id=\"table1\">");
         sb.append("<tr>");
         sb.append("<td align=\"center\">Name</td>");
         sb.append("<td align=\"center\">Desc</td>");
         sb.append("</tr>");
         sb.append("<tr>");
         sb.append("<td align=\"center\"><font color=\"red\"><i>Xue Chen</i></font></td>");
         sb.append("<td align=\"left\">I am a Chinese. </td>");
         sb.append("</tr>");
         sb.append("</table>");
         sb.append("</body>");
         sb.append("</html>");
         label.setSize(600,400);     
         label.setText(sb.toString());
         p.add(label,BorderLayout.CENTER);
         f.getContentPane().add(p,BorderLayout.CENTER);
         f.setSize(new Dimension(600,300));
         f.setVisible(true);     
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JLabel cannot be cast to javax.swing.JEditorPane
         at javax.swing.text.html.FormView.submitData(FormView.java:409)
         at javax.swing.text.html.FormView.actionPerformed(FormView.java:356)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
         at java.awt.Component.processMouseEvent(Component.java:6038)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
         at java.awt.Component.processEvent(Component.java:5803)
         at java.awt.Container.processEvent(Container.java:2058)
         at java.awt.Component.dispatchEventImpl(Component.java:4410)
         at java.awt.Container.dispatchEventImpl(Container.java:2116)
         at java.awt.Component.dispatchEvent(Component.java:4240)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
         at java.awt.Container.dispatchEventImpl(Container.java:2102)
         at java.awt.Window.dispatchEventImpl(Window.java:2429)
         at java.awt.Component.dispatchEvent(Component.java:4240)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

    Hello,
    Thanks for you answer.
    There is a hard problem for this topic.
    how can I get the text value from text field in the html?
    I can got the Document object of the html in implement interface HyperlinkListener.
    Example, I input some chars in the text field<input type="text" name="T1" id="textField">.
    but I can not get the text that I input in the frame.
    Thanks and Best Regards
    here are the codes:
    * Called when a hypertext link is updated.
    * @param e the event responsible for the update
    public void hyperlinkUpdate(HyperlinkEvent e){
         Object src=e.getSource();
         //System.out.println(src);
         HTMLDocument doc=(HTMLDocument)e.getSourceElement().getDocument();//.getDefaultRootElement().getElementCount();
         Element el=doc.getElement("textField");//doc.getDefaultRootElement();
         System.out.println(el.toString());
         if(el!=null){                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Standalone multi-line JLabel vertical alignment

    I have a JLabel subclass that I am using an a Servlet environment, with iText to create a PDF. When I set the vertical alignment to CENTER, the vertical spacing is not correct and the label runs off the bottom of its allocated area. The JLabel is not attached to any Container, it is simply a standalone JLabel with no parent.
    I've done a little digging/debugging and it appears that the View (a javax.swing.plaf.basic.BasicHTML$Renderer) is returning the height of a single line of text from getPreferredSpan(View.Y_AXIS), even though when painted, the label spans several lines. This causes SwingUtilities.layoutCompoundLabel to calculate the wrong starting Y value for the text area.
    When I use this JLabel subclass in a GUI/Swing program that I have, added to a JPanel, it works correctly.
    Looking for any clues or suggestions.

    Partial answer:
    I noticed that in the GUI environment, that the paint() method was being called twice. The first time through, the height of the text was calculated as I described above in the standalone environment - for only a single line of text. The second time through, it calculated the height correctly.
    I changed my subclass to call super.paint(g) (with a dummy Graphics) if there is no parent. This "fixes" the problem in the standalone environment.
    I theorise that it takes 2 passes through the size calculations in the View - once to set the width and again to set the height. Any further insights are welcome.

Maybe you are looking for

  • My shuffle is not recognized in windows xp

    How can I get my shuffle to be recognized in Windows xp?

  • How do u get a Java method to call itself? Not working here.

    How do u get a Java method to call itself? Not working here. I am using the "this" keyword. Thanks. Below, I would like to call checkIt method in itself. Ex. public class ABC { public String checkIt(String abc){ if.... checkIt(abc); }

  • HOW TO REINSTALL THE GATEWAY PLUGIN in Mountain Lion

    The gateway keeps crashing when I try to download sofware off of Amazon's site. Their support instruscted me to look here to find the solution. I would appreciate any advice on how to either replace what I am told is a plug-in - or some other way to

  • Image with /without payload encryption

    Hi all, Can you tell me when I should go for IOS image with payload encyrption and without payload encryption and what are the basic differences? Thanks in advance, Ram

  • Will apple release Xcode for windows

    I have recently tried to get the iOS SDK just to find that Xcode is only availible on the Mac App Store. I am running windows and I dont want to use some 3rd party compiler to develop. I also know that it is not possible to legally run OS X on a Wind