Align a JMenuBar to right in a JFrame

I have next code and I don't know how to alignt to right my menuBar label:
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);

http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html#custom

Similar Messages

  • How can I align a JMenuBar at right ?

    Hello,
    the question is very simple : How can I align a JMenuBar at right ?

    So can you try this ?
    import javax.swing.*;
    public class MenuBarDroite extends JFrame
    public MenuBarDroite()
    super();
    setSize(400,300);
    JMenuBar menu = new JMenuBar();
    menu.add(Box.createHorizontalGlue());
    JMenuItem menuItem1 = new JMenuItem("");
    JMenuItem menuItem2 = new JMenuItem("Menu 2");
    JMenuItem menuItem3 = new JMenuItem("Menu 3");
    JMenuItem menuItem4 = new JMenuItem("Menu 4");
    menu.add(menuItem1);
    menu.add(menuItem2);
    menu.add(menuItem3);
    menu.add(menuItem4);
    setJMenuBar(menu);
    public static void main(String argv[]) throws Exception
    MenuBarDroite m = new MenuBarDroite();
    m.setVisible(true);

  • Changing the alignment of the window title in a jFrame...

    hi.
    is it possible to change the alignment of the window title in a jFrame from left to center / right?
    really appreciate your help on this one. tnx.

    read "dr_ness" posting here:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=353930
    You'll have to extend BasicRootPaneUI and use your custom root pane UI on your frame, so it always draws the title in the center.

  • Can I right-justify a JFrame's title?

    My client wants to display a JFrame's title on the right instead of on the left because we display Hebrew. I think he's wrong, but the customer is alw...
    In the worst case, I can prepend spaces to the title before calling setTitle.
    In the next worst case, I'd have to find the JFrame's UI and render it myself (yuk).
    Is there a cleaner way to right-justify a JFrame's title?
    Thanks,
    Matt

    What look-and-feel are you running under? If that LAF supports custom decoration mode, it should paint the title right-aligned under RTL component orientation.

  • What event will be fired if clicked on top right button of JFrame?

    HI!
    I meet a issue when I developing java GUI application.
    I found when I clicked on top right button x of JFrame . It fire an event windowClosing(event e)
    If I clicked on JButtom and try to close this JFrame . It fire an event windowClosed(WindowEvent e)
            j.setVisible(false);
            j.dispose();
            j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);Is anyway I could fire same event when clicked on either +top right button x+ of JFrame or JButtom ?
    amazing!?
    Thanks!

    camickr,
    NO, you fully understood my question, but also solve it already... you are correct
    clicked on top right button of JFrame and close button are fired on same event.... private void this_windowClosing(WindowEvent e)
    1)clicked on close button fired windowClosing event byWindowEvent windowClosing = new WindowEvent(j, WindowEvent.WINDOW_CLOSING);
    Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(windowClosing);
    2)clicked on top right button of JFrame it fired windowClosing eventI just want an assist to run j.dispose();, will it must fire windowClosed event? anyway to avoid this event?
    May be my explain not clear!

  • Question on aligning char to the right side.

    Hi there,
    I got stuck on displaying numbers in varchar2.
    As I saw the result of a select cmd, if the data type is char,
    the result will be displayed as aligned left. If the data type is number,
    the result is aligned right.
    Say
    create table tmp1(
    id number,
    name varchar2(10)
    insert tmp1 values(1,'1');
    insert tmp1 values(2,'2');
    insert tmp1 values(3,'John');
    select id,name from tmp1;
    id name
    1 1
    2 2
    3 John
    How can I align the name column right?
    In other words, how to make char column right aligned?
    This is the result what I want.(To line them up, I used underline in Name column.)
    id name
    1 ____1
    2 ____2
    3 John
    Thanks.
    Phil

    Use LPAD(col1,10,' ')
    SQL> with data as ( select 1 id, '1' name from dual
      2  union all      select 2,    '2'      from dual
      3  union all      select 3,    'John'   from dual
      4  ) -- data
      5  select id, lpad(name,10,' ') name
      6  from data ;
            ID NAME
             1          1
             2          2
             3       JohnSS

  • Can i call a JMenuBar in a number of JFrame(s) ?

    Hi ,
    I've a program with a number of JFrames.
    I wanted to add a JMenuBar for each frame of my program, this menu bar has the same design code and the same events code in all the program frames, so is there a way to create this JMenuBar once only & call it some how in every JFrame to load it directly instead of writing its same code a lot of times for every JFrame ?
    Thanks ,
    Hesham

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    class Test{
         public static void main( String[] argv ) throws Throwable {
              for(int i=0; i<10; i++){
                   SuperFrame f = new SuperFrame();
                   f.setLocation(i*10,i*10);
                   f.setSize(400,300);
                   f.setVisible(true);
    class SuperFrame extends JFrame{
         private static final long serialVersionUID = 1L;
          * All the menu item goes here
         JMenuBar mbar = new JMenuBar();
         JMenu menu = new JMenu("Menu");
         JMenuItem menuItem1  = new JMenuItem("Close");
         JMenuItem menuItem2  = new JMenuItem("Exit");
         public SuperFrame(){
              super("Testing");
              this.menu.add(menuItem1);
              this.menu.add(menuItem2);
              this.mbar.add(menu);
              this.setJMenuBar(mbar);
              menuItem1.addActionListener(new ActionListener(){
                   @Override
                   public void actionPerformed(ActionEvent arg0) {
                        dispose();
              menuItem2.addActionListener(new ActionListener(){
                   @Override
                   public void actionPerformed(ActionEvent arg0) {
                        System.exit(0);
    }

  • Listing Bookmark Script Align Page Numbers to Right

    Hello,
    I have a script which will list Bookmark Names and then the Page Number after the bookmark as follows:
    Bill Smith  Page#1
    Jeffrey Jones  Page#5
    Christopher James  Page#8
    What I would like the script to achieve is to list the bookmarks and then align the Page numbers to the right side of the pdf instead of jumbled together.
    Can anyone please advise if it is possible to do this in javascript?
    The existing code is as follows:
    /* List all Bookmarks */
    /* Recursively work through bookmark tree  */
    function PrintBookmarks(bm, nLevel)
        if (nLevel != 0) { // don't print the root
            bmReport.absIndent=bmTab*(nLevel-1);
    bm.execute();
                bmReport.writeText(" "+bm.name +" Page "+(bm.doc.pageNum +1));
        if (bm.children != null)
              for (var i = 0; i < bm.children.length; i++)
                PrintBookmarks(bm.children[i], nLevel + 1);                          
    bmTab = 20;
    bmReport = new Report();
    bmReport.size = 2;
    bmReport.writeText(this.title);
    bmReport.writeText(" ");
    bmReport.size = 1.5;
    bmReport.writeText("Listing of Bookmarks");
    bmReport.writeText(" ");
    bmReport.size = 1;
    PrintBookmarks(this.bookmarkRoot, 0);
    global.bmRep = bmReport;  // make global
    global.wrtDoc = app.setInterval(
        'try {'
        +'       reportDoc = global.bmRep.open("Listing of Bookmarks");'
        +'       console.println("Executed Report.open");'
        +'       app.clearInterval(global.wrtDoc);'
        +'       delete global.wrtDoc;'
        +'       console.println("Executed App.clearInterval");'
        +'       reportDoc.info.title = "Bookmark Listings";'
        +'       reportDoc.info.Author = "List Bookmark Sequence";'
        +'} catch (e) {console.println("Waiting...: " + e);}'
        , 100);
    Any help will be much appreciated

    Thank you very much for your help.
    I have modified the script to have the bookmarks and page numbers on separate lines, however the indent does not go further than the middle of the page on the seconde line for the page numbers, no matter how much the indent is modifed  (I am also using version 8 of Adobe).
    Can you please advise how to get the indent to increment past the middle of the page to the right side of the page?
    The script which has been modified is as follows:
    /* List all Bookmarks first then Page Numbers */
    /* Recursively work through bookmark tree  */
    function PrintBookmarks(bm, nLevel)
        if (nLevel != 0) { // don't print the root
           bmReport.absIndent=bmTab*(nLevel-1);
    bm.execute();
                bmReport.writeText(" "+bm.name);
    bmReport.absIndent=(580);
    bmReport.writeText(" Page "+(bm.doc.pageNum +1));
        if (bm.children != null)
              for (var i = 0; i < bm.children.length; i++)
                PrintBookmarks(bm.children[i], nLevel + 1);                          
    bmTab = 20;
    bmReport = new Report();
    bmReport.size = 2;
    bmReport.writeText(this.title);
    bmReport.writeText(" ");
    bmReport.size = 1.5;
    bmReport.writeText("Listing of Bookmarks");
    bmReport.writeText(" ");
    bmReport.size = 1;
    PrintBookmarks(this.bookmarkRoot, 0);
    global.bmRep = bmReport;  // make global
    global.wrtDoc = app.setInterval(
        'try {'
        +'       reportDoc = global.bmRep.open("Listing of Bookmarks");'
        +'       console.println("Executed Report.open");'
        +'       app.clearInterval(global.wrtDoc);'
        +'       delete global.wrtDoc;'
        +'       console.println("Executed App.clearInterval");'
        +'       reportDoc.info.title = "Bookmark Listings";'
        +'       reportDoc.info.Author = "List Bookmark Sequence";'
        +'} catch (e) {console.println("Waiting...: " + e);}'
        , 100);

  • Boxlayout - align things to the right?

    Hi all,
    I have a Box setup with PAGE_AXIS layout.. The Box will contain several JLabel icons (no text) and will be wider than the icons combines. I want the extra space to appear on the left side instead of the right. How do I add this?
    I've tried adding Box.createHorizontaGlue() as the first thing but that doesnt help.
    FYI, this container will implement TableCellRenderer
    So like this:
    [ .........................[  ] [  ][  ][  ][  ][  ][  ]|
    -------------------------------------------

    As already mentioned in a boxLayout you have to set the alignment of each child to get the overall alignment. While that's acceptable in a small container, it can get boring in a bigger environment. So in the long run you might consider switching to more powerful LayoutManager like JGoodies FormLayout (http://forms.dev.java.net/): it lets you define component alignment on a per-column/row basis.
    Personally I switched completely to FormLayout (from nested BoxLayouts which are not too bad, IMO) and developed a visual builder for it (http://swingempire.de/palace/FormBuilder) <g>
    Greetings
    Jeanette

  • FPM toolbar: align buttons to the right?

    I would like to align several buttons in a toolbar to the right (e.g. a "logout" button in a GAF), so position it directly before the standard customize and help buttons. Is it possible in some way?
    Best regards,
    Thomas

    Hi Thomas,
    Change the Alignment From Default value from Left to Right.
    Regards,
    Ragavendra

  • Align outputText on the right

    hello everybody,
    i have the following code in my jsp. i would like to align every first column on the right ... when i put style="align:right" it doesn't do anything ...
    how can i do it ?
    <h:panelGrid columns="2">
    <%--organisation--%>
    <h:outputText value="#{bundle.organisationLabel}" style="align:right" />
    <h:inputText id="organisationLabel" value="" />
    <%--login--%>
    <h:outputText value="#{bundle.loginLabel}" />
    <h:inputText id="userLogin" value="" />
    <%--password--%>
    <h:outputText value="#{bundle.pwdLabel}" />
    <h:inputSecret id="userPwd" value=""/>
    <h:commandButton id="submit" action="success" value="OK" />
    </h:panelGrid>

    ok but if i use columnclass in panelgrid, it will
    apply the style to all the columns. what i want is to
    align the first column on the right, not the second.This is what the columnClasses attribute is for. You want something like:
    columnClasses="leftalignclass,rightalignclass"
    This says "use style 'leftalignclass' for the first column and 'rightalignclass' for the second column."
    Hope that helps.

  • Align Formula Values to Right Hand Side

    I am having a formula filed inside my crystal report that i want to align in the right direction when it get printed on my crystal report
    here is my formula
    IF ({ABC.NAME} = "John") THEN  {Notes.NOTE_details}
    else {ABC.old_ENTRY}
    Please advise
    thanking in advance

    Hi Muhammad,
    Is {Notes.NOTE_details} and {ABC.old_ENTRY} or images ? Or is it a long text ? what is the data type of these fields ?
    Can you try to right click on the field and go in Format field-- Common--Horizontal Alignment : select Right from the drop down and see..
    -Sastry

  • Align indicator value to right

    Hi,
    how can I set on default the alignement of indicator values to right?
    this should be possible I guess.
    And how can I set on default my changes on numeric properties?
    yves

    Hello,
    If you want to make it default, the best thing to do is create your own control.
    Right click on the control, select advanced...customize, here you can do what you want to your indicator/control, also the precision...
    For changing the precision by default (and other default options) I found something thet might be helpfull:
    http://labview.brianrenken.com/INI/undoc.shtm
    Hope it helps...
    Paulo

  • How to align menu to the right

    Hi
    How do I align a menu to the right? In the Design mode.
    Previously I've used menuBar.add( Box.createHorizontalGlue() ), but I guess you should be able to do it without coding.
    Using Netbeans 4.

    How do I do that? Where?
    " WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor."

  • How to align text {center/left/right} in  the column of ALV grid

    Hai all,
    I am displaying one check box in the ALV grid, but default it is coming left align in the column,
    how can i assign it to the center of the column.
    Thanks,
    SREEVATHSAVA.G
    Edited by: SREE on Aug 14, 2009 7:53 AM

    Hi,
    DATA:
      lr_model type ref to cl_salv_wd_config_table,
      lr_col type ref to cl_salv_wd_column.
    lr_col = lr_model->if_salv_wd_column_settings->get_column( 'EMPID' ).
    lr_col->SET_H_ALIGN(value = CL_WD_TABLE_COLUMN=>E_H_ALIGN- CENTER).
          AUTO TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '00', " TableColumnHAlign.auto
          CENTER TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '01', " TableColumnHAlign.center
          FORCED_LEFT TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '04', " TableColumnHAlign.forcedLeft
          END_OF_LINE TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '05', " TableColumnHAlign.endOfLine
          FORCED_RIGHT TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '06', " TableColumnHAlign.forcedRight
          BEGIN_OF_LINE TYPE WDY_UIE_LIBRARY_ENUM_TYPE VALUE '07', " TableColumnHAlign.beginOfLine
    Regards,
    Lekha.

Maybe you are looking for

  • Hi all, Got a doubt on Serialization..read on..quite interesting

    package package1; import java.io.*; public class Dog implements java.io.Serializable{ transient private Collar theCollar; //Not serialiazable private int dogSize; public Dog(Collar collar,int size){      theCollar=collar;      dogSize=size; public Co

  • Adobe CS3 Flash Programmer Needed

    I'm using Camtasia 5.0.2 to create a Flash .flv video. Camtasia 5.0.2 produces the following 9 files to be played in an Internet browser (example is a 2.5 min video with file name, Test 001 single FLV w PIP and TOC 02 21 2008): FlashTemplate.css 1 KB

  • Error in Inbound delivery monitor (VL06i)

    Dear Friends, I am getting error in vl06i, when i do partial GR for inbound deliveries. The error is Item 000110 does not exist *Material is not the same confirmation and delivery. Is the first error is because the particular item is not confirmed fo

  • Project conflict with dynamicall​y called VIs

       I have a largish project in LV 2010 in XP and W7.  It's all in a project, as I build the main VI into an .exe.  There are numerous other top-level VI's that are called dynamically.  I use source code distributions to build them with their diagrams

  • Way to fix the version 6 upgrade problem

    I have Norton Internet Security and this is what worked for me... Follow the step-by-step instructions Itunes gives that relates to going to Start-My Computer- Tools - Folder Options - etc. Update your firewall - mine was already updated though. Open