java - After changing JLabel text it will not reposition -


I have JDialog with a title written on top I call it for two separate cases and if it is the default If not, then I change the text to something else. It works fine but the situation is far too far to correct.

I have tried several methods like:

  TitleText.setText ("edit fuse"); TitleText.setAlignmentY (JLabel.CENTER_ALIGNMENT); //TitleText.setHorizontalAlignment (JDialog). //TitleText.setLayout (New Flow Layout (Flow Layouts. LEFT));  

None of them even transfers the text. I am using a free design layout for full jedialogy. If I want to make just one more gelable and hide / hide, but I thought it would be easy, do anyone know how to do this?

I am using a free design layout for JDialog full

  • Do not do that if you want to be the title and focus of JLABL to stay on top. Instead, the main JPN of the ZDIA has used the border layout, and JAlabel has been added to the border layout. PAGE_START, also known as the border layout.
  • The main JPanel again likely to be the rest of your GUI yourself you can hold in the JPanel, using your own layout manager, and other JPanels, your BorderLayout.CENTER position.
  • Also, do not use the JLabel.CENTER_ALIGNMENT , a boat, but using JLabel.CENTER , is an integer, which setHorizontalAlignment The appropriate parameter is (...) method.
  • Finally, I recommend you an unsolicitated side to make sure that your variable names begin with a lowercase letter and not uppercase letters so that they have to be followed by Java naming rules. It is important that you want others, such as people who want to help you in this way, to understand your code faster

For example: .

  Import java.awt.BorderLayout; Import java.awt.Dimension; Import java.awt.Font; Import java.awt.event.ActionEvent; Import java.awt.event.ActionListener; Import javax.swing *; @SuppressWarnings ("serial") JPanel in the public class layout format {Private constant last float size = 32; Personal fixed final difference TIMER_DELAY = 2000; Private string [] TITLE_STRINGS = {"Heading 1", "Heading 2", "Something Random Title", "Fiber Law!", "Snuffs Drill!" }; Private IT & End = 0; Private JLabel titledLL = new JLABEL (TITLE_STRINGS [Title Index], JLABEL. CEF); Public Layout Example () {titleLabel.setFont (titleLabel.getFont (.) DeriveFont (font BA, SIZE)); Set layout (new border layout ()); Add (Title Labels, Border Layout. PAGE_START); // can be added below add the rest of your GUI (Boksksent Rigid area (new Dimension (500, 300)), border layout. New Timer (TIMER_DELAY, new ActionListener () {@Override public void actionPerformed (ActionEvent e) {titleIndex ++; titleIndex% = TITLE_STRINGS.length; titleLabel.setText (TITLE_STRINGS [titleIndex]);}}). start ();} private static make Andsoji (Whoid) {Jefrem frame = new Jefram ( " Leautacsamn "); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); Frame.getContentPane (). add (new Leautudahrn ()); frame.pack (); frame.setLocationRelativeTo ( Uny); FrameksetVisible (right);} public static void main (String [] Arges) {SwingUtilities.invokeLater (new Rnnabl) (public void run () {createAndShowGui ();}});}}  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -