How to make a caption on a JButton 2 lines

I can't seem to get a JButton to have text for 2 lines...I want the first line to say "New", and the second line to say "Merge"...
I have tried several things, but I don't feel like wasting all my time figuring this out...I am sure it is something simple...anyone?

Here is a sample, this is only a sample. I does not have most the functionality of the interaction between JButton and the text on it. I do not have time to duplicate it all for you. You might try looking at the source code for JButton and its UI to see how it is handled by Sun. There is a file on your system called src.jar which has source code in it. Learn how to use the jar command (or use winzip) to get source code out of it. Learn to search the forum.import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Test extends JFrame {
    public Test() {
     setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
     Container content = getContentPane();
     String[] test = {"Hello","There"};
     JPanel jp = new JPanel();
     jp.add(new TestButton(test));
     content.add(jp, BorderLayout.SOUTH);
     setSize(200,200);
     show();
    public static void main( String args[] ) { new Test(); }
class TestButton extends JButton {
    String[] lines;
    public TestButton(String[] Lines) {
     lines=Lines;
     setPreferredSize(new Dimension(100,20*lines.length+10));
    public void paintComponent(Graphics g) {
     super.paintComponent(g);
     if (lines!=null) {
         for (int y=0; y<lines.length; y++) {
          g.drawString(lines[y], 10, y*20+20);
}

Similar Messages

  • How to make fields required in an updateble multi line form?

    How to make fields required in an updateble multi line form?

    You need to create a validation item that is triggered when the user clicks the submit button.
    Set the validation type to "Function Returning Error Text".
    Then add your validation into the "Validation Expression 1" field. Something like:
    BEGIN
    FOR I IN 1.. HTMLDB_APPLICATION.G_F02.COUNT LOOP
    IF HTMLDB_APPLICATION.G_F02(I) IS NULL THEN
    RETURN 'Please enter in a value for xxxxx on line ' || TO_CHAR(I,'0');
    END IF;
    END LOOP;
    RETURN NULL;
    END;
    As long as the function returns a string, an error is generated - as there is no single field where this error can be displayed, it will need to be displayed "On Error Page".
    If the return value is NULL, then the fields are valid and the submit process can continue.
    Andy

  • How to make plant in shipping cond tab for line item in sales doc mandatory

    Hi
    How to make plant as mandatory for a sales document say quotation mandatory ? I went to SPRO-> Basic Fucntion - > log of incomplete terms ->  Define incomplete Groups -> B.selected sales -Item -> Created new procedure Z001 with fielda VBAP - WERKS ,selected screen name PDE2 and checked warning check box.
    When i goto Assign incompleteness procedures I donot have option to assign it sales document item level procedure i will only get sales doc header procedure to assign it to document type quotation.
    How to make plant as mandatory for each line item in quotation?
    Thanks,
    Vaishnavi

    Include: MV45AFZB
    Form  USEREXIT_CHECK_VBAP
    In our business scenario, we have used the same ,But  Plant is mandatory only for 1st line item-
    source code:
    IF vbak-vkorg = '1000' OR vbak-vkorg = '2000'.
        IF sy-tcode = 'VA31' OR
           sy-tcode = 'VA11' OR
           sy-tcode = 'VA21' OR
           sy-tcode = 'VA41' OR
           sy-tcode = 'VA01' .
          IF vbap-werks IS INITIAL AND
             vbap-posnr EQ '000010'.
            MESSAGE e398(00) WITH 'Please enter the plant for first line'.
          ENDIF.
        ENDIF.
      ENDIF.
    Help:
    Through this form exit we are making the "plant' field (for the ist  &*
    & line item ) mandatory for the sales document . This interns helps us &
    & to create the sales document numner according to the plant (Region)  &
    *& of the Plant
    Hope it clears. take assistance of your ABAPer.

  • How to make a round circle with the notch line

    Hi
    If I in Illustrator on the same layer make a Elipse with a 50pt stroke (blue color) and then i make 2 lines with a 20pt stroke (black color), so its lookslike a cross and rotate it 45 degr.
    Then i Outline the 3 elements "Outline Stroke" and align the 3 elements H and V Align Center.
    Now i want to cut the black lines out of the blue cirkel, so I get 4 pices with a "non-color" space between, but wjen i select the 3 elements and use Pathfinder -> Shape Modes, then i can't cut the lines out...
    What do i do wrong.
    What i want to end up with is something like this cirkel, so i can tage the 3 pices and give em another color.

    I did it this way.
    1) Ungroup a copy of a pie chart to disconnect the data.
    2) Draw a filled circle on top of the chart.
    3) Pathfinder Divide and delete the pieces in the centre.
    4) Select the remaining pieces and Object > Expand.
    5) Select just the expanded strokes and pathfinder Unite
    6) Pathfinder Divide and delete the United stroke.

  • How to make an editable bulleted list with multiple lines and custom bullets?

    How do I create an editable bulleted list in Acrobat Pro? I've figured out how to add text fields with multiple lines, and how to add a list box, but I don't see the check box for multiple lines in the list box or how to add bullet points. Can someone please give me step by step instructions? Also is it possible to use custom bullet points?

    Is it a text field or a list box field? The two are not the same...
    The bullets are something that the user will have to enter manually (into a text field, they can only select values in a list-box).
    They can use any unicode character, or special characters if the font used for that field allows for it. You can't use images for the bullets, if that's what you mean.

  • How to make a long Legend contained in multiple line

    I have a PieChart needs legends. Some of them are very long.
    Is it possible to make long legends written in
    multiple lines? Here is the code for the PieChart and Legend:
    <mx:PieChart id="byMake" height="325" width="100%"
    dataProvider="{make.product}" showDataTips="true" >
    <mx:series>
    <mx:PieSeries field="quantity" nameField="brand"
    startAngle="0" />
    </mx:series>
    </mx:PieChart>
    <mx:Legend dataProvider="{byMake}" horizontalAlign="left"
    />

    "glen08" <[email protected]> wrote in
    message
    news:giem8i$e0j$[email protected]..
    >I have a PieChart needs legends. Some of them are very
    long. Is it possible
    >to
    > make long legends written in
    > multiple lines? Here is the code for the PieChart and
    Legend:
    >
    > <mx:PieChart id="byMake" height="325" width="100%"
    > dataProvider="{make.product}" showDataTips="true" >
    > <mx:series>
    > <mx:PieSeries field="quantity" nameField="brand"
    startAngle="0" />
    > </mx:series>
    > </mx:PieChart>
    > <mx:Legend dataProvider="{byMake}"
    horizontalAlign="left" />
    Try this as your itemRenderer
    package com.magnoliamultimedia.views
    import flash.display.DisplayObject;
    import mx.charts.LegendItem;
    import mx.core.UITextField;
    public class WrappingLegendItem extends LegendItem
    public function WrappingLegendItem()
    super();
    override protected function createChildren():void{
    super.createChildren();
    for (var i:int=0;i<numChildren; i++){
    var child:DisplayObject=getChildAt(i);
    var txt:UITextField = child as UITextField;
    if (!(txt==null)){
    txt.wordWrap=true;
    txt.invalidateSize();

  • How to make reports on a batch or command line?

    The company where I work have bought recently the Crystal Report product.
    We want to generate reports directly on a directory in batch mode. Everyday, we need to generate some PDFs. Is it possible to write a batch or to use the crystal report executable in command line?
    We develop applications in Java, so if you have some solution using the Java language, it will be better for us.

    I recommend the just-released Crystal Reports for Eclipse Version 2:
    [https://www.sdn.sap.com/irj/boc/crystalreports-java]
    and Java code such as:
    reportClientDocument = new ReportClientDocument();
    reportClientDocument.setReportAppServer(ReportClientDocument.inprocConnectionString);
    reportClientDocument.open(reportPathString, OpenReportOptions._openAsReadOnly);
    byteArrayInputStream = (ByteArrayInputStream) reportClientDocument.getPrintOutputController().export(ReportExportFormat.PDF);
    then take the byte[] from the stream as sream as you like.
    Sincerely,
    Ted Ueda

  • Hint captions - how to make them work

    Hello all,
    Can someone shed light how to make hint captions work? I created a training progect with all default options - it generates all four caption: Text, success, failure and hint.
    The problem is that hint captions are not shown when hoovering over the clickbox area... in fact they never show up whatever i do.
    Am I missing something obvious here?
    Thanks!

    OK.  Thanks.
    Now do one more thing: Select the click box object that you can see in this example and from the Modify menu item, click Arrange > Bring to Front.  Then republish and test.
    This is a bit of a long shot, but what I'd checking for here is that there is a known issue in Cp 5x where sometimes an object is shown as being at the top level layer in the timeline when in fact it may be several layers deep. So your click box might actually be underneath another object and thereby NOT seeing the mouseover to trigger the Hint caption.

  • How to make a Input Field with multiple lines?

    hey folks,
    i need to make a popup window or a dynpro with 2 input fields, where the user can write on multiple lines. why isnt there such an input field in the screen painter? how can i make this? if i can do this with a dynpro it would be nice but a popup with that feature would be better. didnt found any infos anywhere except for that thread, but its answer didnt work with my dynpro:
    How to make a input/output field with multiple lines
    thx for any helping answer

    i made it just like in that thread but there is an error message telling that gv_custom_container is not declared.
    *  MODULE status_0110 OUTPUT
    MODULE status_0110 OUTPUT.
      CREATE OBJECT custom_container
        EXPORTING
          container_name              = 'TEXT_CONTROL'
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5.
      CREATE OBJECT text_editor
        EXPORTING
          parent                     = gv_custom_container
          wordwrap_mode              = cl_gui_textedit=>wordwrap_at_windowborder
          wordwrap_to_linebreak_mode = cl_gui_textedit=>false
        EXCEPTIONS
          error_cntl_create          = 1
          error_cntl_init            = 2
          error_cntl_link            = 3
          error_dp_create            = 4
          gui_type_not_supported     = 5.
      SET PF-STATUS 'STATUS_0110'.
      SET TITLEBAR 'TITLE'.
    ENDMODULE.                    "status_0110 OUTPUT
    Edited by: rafe b. on Oct 26, 2009 2:56 PM

  • How to make new line in JButton.setText()?

    how to make new line in JButton.setText()?
    I want to set the text of jbutton in tow line ,as follows
    | jbutton-line1 |
    | xxxxxxx-line2 |
    i konw i can jbtton.settext("<html>line1<br>line2</html>");
    but i find it's ugly using html,
    is there anyother way to create new line in JButton's Text

    As for the above comment....
    I thought the question was well purposed. Using HTML was not acceptable in this instance, which was made clear, so why critisize his comments? "Using HTML" is a poor solution, it does NOT work in many instances due to browser, OS variations. Usually the "common answer" is never a COMPLETE answer.
    Possible Solution:
    Use JLabels to render the text on the button.
    import javax.swing.*;
    import java.awt.*;
    public class ButtonMaker {
    public static void makeButton(JButton jb, String[] titleList) {
    jb.setLayout(new FlowLayout());
    for (int i = 0; i < titleList.length; i++) {
    JLabel tmpLabel = new JLabel(titleList);
    tmpLabel.setForeground(Color.black);
    jb.add(tmpLabel);
    public static void clearButton(JButton jb) {
    Component[] cList = jb.getComponents();
    for (int i = 0; i < cList.length; i++) {
    if (cList[i] instanceof JLabel)
    jb.remove(cList[i]);
    Known Limitations:
    1. Flowlayout does not work well with single line text buttons... perhaps another layout manager may work better for various buttonsizes-linenumber combos.
    2. Mac OSX : The default UI for Mac OS X (and above it seems), is to have rounded edged buttons. These rounded edges are destoryed when using JLabels, leaving a square, blocky button in its place.
    POSSIBLE SOLUTION:
    (this is ugly and time consuming)
    - create images of the button with text on them.

  • How do I add text to individual slides in slideshow to make a caption?

    How do I add text to individual slides in a slideshow in order to make a caption on each slide?

    It will depend on the theme you are using for the slide show.
    For some themes you can add custom text or metadata to the slide as captions, for example the "Classic" theme.  Use the "Selected Slides" tab and enable "Text".

  • How to make a JPanel selectable

    When extending a JPanel and overriding the paintComponent() method the custom JPanel can not be selected so that it gets for example KeyEvents.
    But if I make the new Class extend a JButton it gets of course selected and able to receive for example KeyEvents.
    My question is therefore; what does the JButton implement that a JPanel doesn&#8217;t so that a JButton gets selectable? Or in other words; how to make a JPanel selectable?
    Aleksander.

    Try this extended code. Only the first panel added can get the Focus.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class Test extends JFrame
      public Test()
        setLocation(400,300);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        JPanel panel1 = new JPanel(new BorderLayout());
        JPanel panel2 = new JPanel(new BorderLayout());
        ImagePanel imgPanel = new ImagePanel();
        panel1.setFocusable(true);
        panel2.setFocusable(true);
        panel1.setPreferredSize(new Dimension(0, 50));
        panel2.setPreferredSize(new Dimension(0, 50));
        panel1.setBorder(BorderFactory.createLineBorder(Color.RED,     4));
        panel2.setBorder(BorderFactory.createLineBorder(Color.CYAN,    4));
        imgPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 4));
        panel1.add(new JLabel("Panel 1"), BorderLayout.CENTER);
        panel2.add(new JLabel("Panel 2"), BorderLayout.CENTER);
        getContentPane().add(panel1, BorderLayout.NORTH);
        getContentPane().add(panel2, BorderLayout.SOUTH);
        getContentPane().add(imgPanel, BorderLayout.CENTER);   
        pack();
        panel1.addKeyListener(new KeyAdapter(){
            public void keyPressed(KeyEvent ke){
                System.out.println("Panel1");}});
        panel2.addKeyListener(new KeyAdapter(){
            public void keyPressed(KeyEvent ke){
                System.out.println("Panel2");}});
      public static void main(String[] args){new Test().setVisible(true);}
    class ImagePanel extends JPanel
      Image img;
      public ImagePanel()
        setFocusable(true);
        setPreferredSize(new Dimension(400,300));
        try{img = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("Test.gif"), "Test.gif"));}
        catch(Exception e){/*handled in paintComponent()*/}
        addKeyListener(new KeyAdapter(){
          public void keyPressed(KeyEvent ke){
            System.out.println("ImagePanel");}});
      public void paintComponent(Graphics g)
        if(img != null)
          g.drawImage(img, 0,0,this.getWidth(),this.getHeight(),this);
        else
          g.drawString("This space for rent",50,50);
    }

  • How to make indented text in Muse

    How to: make indented text in Muse, like a list with bullits

    I read on another post that you can do ALT 0149 (WIN) and it will create a bullet in Muse.  I tried ALT+0149 and then ALT then 0149 and neither one created a bullet so I must not be understanding the key shortcuts to create the bullet.
    The above video is not captioned (I'm deaf) so I don't understand how he's creating the bullets.  Can someone explain what I'm doing wrong?
    PS - when videos are made, it would be nice if you brought some kind of graphic on saying (for example) "Press the [whatever] key" so deaf people can see what's happening.

  • How do you add captions to photos in iDVD slideshows?

    Is there a way to add captions to photos once you've put them into slideshows on iDVD? Or, if not, is there another way to add captions to them, though another apple application such as iPhoto? I haven't been able to figure out how to make captions for photos in iPhoto slideshows either. Please help!

    Welcome to the Apple Discussions. if you're creating the slideshow from stills in iDVD use the Settings button at the bottom to bright up the pane where you can add titles and comments. The downside of that is every photo will automatically have it's file name or title entered. If you don't want that then while you're in iPhoto use the Photos->Batch Change->Title->None option before you import into iDVD. Then none of them will have the titles entered and you can add them to just those that you want. Or you can add them while in iPhoto before importing.
    OT

  • How to make my SLIDER control the movement of animations: ( fast & slow)

    hello!
    i wanna do water dropping animations. using a slider, to controlled how fast and slow the animations can be.
    please help me!!!

    I need help about controlling my animations with slider.
    I already know about slider & water dropping animations, but how to make this 2 things interract.
    Right now i have slider and water dropping animations, but when i scroll my slider up and down, my animations still with the same speed.
    In my opinion, i think, i need to make one func/method that take var from slider and transfer it to water dropping var(controlling the speed of anim...).
    eg: (coding)
    //class bla...bla...bla...
    JLabel sliderValue = new JLabel("Value = 25"); // slider var
    JSlider sliders = new JSlider(JSlider.VERTICAL, 0, 50, 25);
    WaterDropPanel drop = new WaterDropPanel(); // waterdropclass
    JButton start = new JButton("Start"); // start anim...
    JButton stop = new JButton("Stop"); // stop anim...
    //waterdrop class...
    class BulatanPanel extends JPanel implements Runnable
    private Thread runner;
    int yPos = -20;
    int yMove = 4;
    void playAnimation()
    if (runner == null);
    runner = new Thread(this);
    runner.start();
    void stopAnimation()
    if (runner != null);
    runner = null;
    public void run()
    Thread thisThread = Thread.currentThread();
    while (runner == thisThread)
    yPos += yMove;
         if (yPos > 310)
         yPos = -20;
    repaint();
    try
    Thread.sleep(10); // var controlling the speed of anim...
         catch (InterruptedException e) {}
    public void paintComponent(Graphics comp) {
    Graphics2D comp2D = (Graphics2D)comp;
    comp2D.setColor(Color.black);
    comp2D.fillRect(0, 0, 250, 240);
         comp2D.setColor(Color.red);
    comp2D.fillOval(110, yPos, 20, 20);
    // slider event handling... ( In my constructor)
    public void stateChanged(ChangeEvent e)
    sliderValue.setText("Value = " + ((JSlider) e.getSource()).getValue());
    I'M SORRY IF ITS TOO LONG

Maybe you are looking for

  • Multiple Email Accounts on Mail

    morning all, I have a MACBook Pro Retina 2013 model running Software  OS X 10.9.4 (13E28). I have set up all of my email accounts (3 of them) in the default Mail program on the MAC. When I create a mail it always uses (defaults) to my yahoo account,

  • The request for account "iCloud" failed.  The server responded with "400" to operation CalDAVAddSubscriptionCalendarQueueableOperation

    Does anyone know how to fix this problem?  Or even what the problem is?  I am trying to subscribe to a calendar and every time I do, it gives me this response: The request for account "iCloud" failed. The server responded with "400" to operation CalD

  • USB causes Mac Pro to crash.

    Hi Guys, I've got a MacPro1,1, I have an issue with the USB on it. Now and again, when ever I eject my USB it totally locks my Mac Pro up and I have to cold reboot it (I.E turn the power off). The USB was formatted with the Mac file system, and I alw

  • CS3 windows to mac problem

    Mac OS 10.4.11, 1.8 Ghz, 4 gigs ram, Adobe CS3 Suite I was given an AICS3 Windows file. I placed into IDCS3, preview looked fine, job printed fine. All links intact and fonts were outlined. Client had a change, so I opened the AI file in (Mac) AICS3,

  • Complex Splits - Can I Create my Own?

    Hi, Im just wondering if in Mainstage 2. can i creat my own complex splits with the freedom of what ever instruments i want. Like one side would be dragndrop sample kit, the middle would be an ultra beat, and the third, right side, woulc be a keyboar