JLabel spacing

I have a component with a JLabel above it. Both of these components are centered relative to the component that is next to it. However, it is not coming out quite right. It appears that the JLabel has 4 pixels of extra space above it. This spacing I believe is due to the font and not from the insets of the GridBagLayout. If I double the size of the JLabel's font, the spacing increases to 8 pixels. I also tested this with a small program that adds a single JLabel to a JFrame:
public class MainClass {
  public static void main(String[] args) {
    javax.swing.JFrame frame = new javax.swing.JFrame();
    javax.swing.JLabel label = new javax.swing.JLabel("Environment-gy");
    label.setBackground(java.awt.Color.RED);
    frame.getContentPane().add(label);
    frame.getContentPane().setBackground(java.awt.Color.RED);
    frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}If you run this, you will notis that the "gy" in the label has only a single pixel of spacing below, but there are 4 pixels of spacing above the text. Is there any way to remove these 4 pixels? The components do not center correctly with them in there. Even in the test program, the label does not appear to be centered exactly. It appears to be too far down from the top, albeit subtely.
I cannot just kludge this, however, because this application will be run on a number of different environments and there is no way to know what exact font and font size will be used.

In the future Swing related questions should be posted in the Swing forum.
If the past you have been given a link to the Swing tutorial, specifically you have been given the link on "How to Use Layout Managers". So read the tutorial, choose the appropriate layout manager and use the appropriate methods to control the spacing.

Similar Messages

  • Letter spacing for JLabel

    Hi all,
    Is there any way to specify letter spacing of a text in Jlabel?

    not really, without writing a custom UI delegate, which can be a real pain in ass for anything that has text in it.
    I would look into trying to find a standard font that puts in the spacing you want. Or, if you really want, you can get the spacing you need using a graphics editor program, then save that as an image, and use that image as an icon on your label.
    - Adam

  • Spacing problem

    Hi,
    I am working on Java Swings and Iam new to it.
    Can anybody help me with my problem please...
    I have 5 panels and all these are palced in one main panel.
    I have :
    Panel1
    Panle2
    Panel3
    Panel4
    Panle5
    Panel6
    panel7
    All these are placed in main panel according to the ActionListener.
    when event1 is triggered,I need to place panel1,Panel2,Panel3,Panel4,Panel5 in Main panel.
    When event2 is triggered ,I need to place panel1,panel6,panel3,panel4,panel5 in main Panel.
    When event3 is triggered ,I need to palce panel1,panel2,panel7,panel4,panel5 in main panel.
    I coded all the panels and placed the components.But I when i place the panels ,I am getting spacing problems.
    and when I resize the main panel,I am losing components in the panels.
    Can anybody help with code please.
    I also need calender textfield with small icon besides it that pops up calender and when user selects date it should take in "yyyymmdd" format.
    Thanks,
    Tutika.

    Don't forget to use the [url
    http://forum.java.sun.com/help.jspa?sec=formatting]Cod
    e Formatting Tags so the posted code retainsits original formatting.
    If you add components to a visible panel then you
    need to revalidate() the panel so the layout manager
    can be invoked again.
    sorry,
    Here is my view code:
    public class CalenderAdmin1 extends JFrame {
         private static final long           serialVersionUID = 1L;
         // Top panel to which all the panels are attached
         // based upon events
         public JPanel jContentPane = null;
         private JScrollPane jScrollPaneContent = null;
         // Main panel variadle declaration
         private JPanel mainPanel = null;
        private JLabel jLblCalender = null;     
         private JComboBox jCmbBxCalender = null;     
        private JRadioButton jRBttnDay = null;     
         private JRadioButton jRBttnEvent = null;
         // counselorPanel variable declaration
         private JPanel      counselorPanel = null;
         private JLabel jLblCounselor = null;
         private JLabel jLblLocation = null;
        private JLabel jLblType = null;
         private JLabel jLblType1 = null;
         private JComboBox jCmbBxCounselor = null;
         private JComboBox jCmbBxLocation = null;     
         private JComboBox jCmbBxType = null;
        private JRadioButton jRBttnOffice = null;
         private JRadioButton jRBttnCounselor = null;
    //      officePanel variable declaration
         private JPanel      officePanel = null;
        private JLabel jLblPanelOfficeType = null;
         private JLabel jLblPanelOfficeLocation = null;
        private JComboBox jCmbBxPanelOfficeLocation = null;
         private JComboBox jCmbBxPanelOfficeType = null;
         // timepanel variable declaration
         private JPanel      timePanel = null;
         private JLabel jLblStartDate = null;
         private JLabel jLblStartTime = null;
         private JLabel jLblEndTime = null;
         private JTextField jTxtFStartDate = null;
        private JComboBox jCmbBxStartTimeHrs = null;
        private JLabel jLblStartTimeColon = null;
         private JComboBox jCmbBxStartTimeMin = null;
         private JComboBox jCmbBxEndTimeHrs = null;
         private JLabel jLblEndTimeColon = null;
         private JComboBox jCmbBxEndTimeMin = null;
         // recurrencePanel variable declaration
         private JPanel      recurrencePanel = null;
         private JLabel jLblRecurrence = null;
        private JLabel jLblSunday = null;
         private JLabel jLblMonday = null;
         private JLabel jLblTuesday = null;
         private JLabel jLblWednesday = null;
         private JLabel jLblThursday = null;
         private JLabel jLblFriday = null;
         private JLabel jLblSaturday = null;
        private JCheckBox jChkBxMonday = null;
         private JCheckBox jChkBxTuesday = null;
         private JCheckBox jChkBxWednesday = null;
         private JCheckBox jChkBxThursday = null;
         private JCheckBox jChkBxFriday = null;
         private JCheckBox jChkBxSaturday = null;
         private JCheckBox jChkBxSunday = null;
         private JLabel jLblEndDate = null;
         private JTextField jTxtFEndDate = null;
         // butonsPanel varaiable declaration     
         private JPanel      buttonsPanel = null;
        private JButton jBttnCancel = null;
         private JButton jBttnSave = null;
         // eventsPanel variable declaration
         private JPanel  eventsPanel = null;
        private JLabel jLblEvents = null;
         private JLabel jLblEventType = null;
         private JLabel jLblEventStartTime = null;
         private JLabel jLblEventEndTime = null;
         private JComboBox jCmbBxEventType = null;
         private JComboBox jCmbBxEventStartTimeHrs = null;
         private JComboBox jCmbBxEventStartTimeMin = null;
         private JComboBox jCmbBxEventEndTimeHrs = null;
         private JComboBox jCmbBxEventEndTimeMin = null;
        private JLabel jLblEventStartTimeColon = null;
         private JLabel jLblEventEndTimeColon = null;
         private JButton jBttnAdd = null;
         String[] calender,counselor,location,type,type1;
       //     Contructor
         public CalenderAdmin1() { 
               super();
                initialize();
          * This method initializes this
          * @return void
         private void initialize() {
                 this.setSize(750, 500);
                   this.setPreferredSize(new Dimension(600, 600));
                   this.setContentPane(getJScrollPaneContent());
                   this.setTitle("Calender Administrator");
                   this.setVisible(true);
         // Scroll Pane
         private  JScrollPane getJScrollPaneContent() {
              if (jScrollPaneContent == null) {
                   jScrollPaneContent = new JScrollPane();
                   jScrollPaneContent.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
                   jScrollPaneContent.setViewportView(getJContentPane());
              return jScrollPaneContent;
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         public JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(null);
                   //jContentPane.setLayout(new GridLayout(5,0,0,0));
                   //jContentPane.setLayout(new BoxLayout(jContentPane,BoxLayout.Y_AXIS));
                   jContentPane.add(getmainPanel(),null);
                   //jContentPane.add(getofficePanel(),null);
                  jContentPane.add(getcounselorPanel(),null);
                  //jContentPane.add(geteventsPanel(),null);
                   jContentPane.add(gettimePanel(),null);
                   jContentPane.add(getrecurrencePanel(),null);
                   jContentPane.add(getbuttonsPanel(),null);
              return jContentPane;
         private JPanel getmainPanel(){
              if (mainPanel ==null){
                   mainPanel = new JPanel();
                   mainPanel.setLayout(null);
                   //jPanel1.setBorder(new javax.swing.border.TitledBorder("1"));
                   mainPanel.setBounds(new Rectangle(0, 0, 700, 85));
                   mainPanel.add(getjLblCalender(),null);
                   mainPanel.add(getjCmbBxCalender(),null);
                   mainPanel.add(getjRdBttnDay(),null);
                   mainPanel.add(getjRdBttnEvent(),null);
              return mainPanel;
         public JPanel getcounselorPanel(){
              if(counselorPanel==null){
                   counselorPanel = new JPanel();
              //jPanel2.setLayout(new BoxLayout(jPanel2,BoxLayout.Y_AXIS));
                   counselorPanel.setLayout(null);
                   //jPanel2.setBorder(new javax.swing.border.TitledBorder("2"));
                   counselorPanel.setBounds(0, 65, 700, 125);
                   counselorPanel.add(getjLblCounselor(),null);
                   counselorPanel.add(getjCmbBxCounselor(),null);
                   counselorPanel.add(getjLblLocation(),null);
                   counselorPanel.add(getjCmbBxLocation(),null);
                   counselorPanel.add(getjLblType(),null);
                   counselorPanel.add(getjCmbBxType(),null);
                   counselorPanel.add(getjLblType1(),null);
                   counselorPanel.add(getjRdBttnOffice(),null);
                   counselorPanel.add(getjRdBttnCounselor(),null);
              return counselorPanel;
         private JPanel gettimePanel(){
              if (timePanel == null){
                   timePanel=new JPanel();
                   //jPanel3.setBorder(new javax.swing.border.TitledBorder("3"));
                   timePanel.setLayout(null);
                   timePanel.setBounds(0, 170, 700, 100);
                   timePanel.add(getjLblStartDate(),null);
                   timePanel.add(getjTxtFStartDate(),null);
                   timePanel.add(getjLblStartTime(),null);
                   timePanel.add(getjCmbBxStartTimeHrs(),null);
                   timePanel.add(getjLblStartTimeColon(),null);
                   timePanel.add(getjCmbBxStartTimeMin(),null);
                   timePanel.add(getjLblEndTime(),null);
                   timePanel.add(getjLblEndTimeColon(),null);
                   timePanel.add(getjCmbBxEndTimeHrs(),null);
                   timePanel.add(getjCmbBxEndTimeMin(),null);
                   JLabel jLblC1 =  new JLabel ();
                   jLblC1.setBounds(new Rectangle(25, 70, 60, 20));
                   jLblC1.setText("new");
                   jPanel3.add(jLblC1);
                   JLabel jLblC2 =  new JLabel ();
                   jLblC2.setBounds(new Rectangle(25, 90, 60, 20));
                   jLblC2.setText("new");
                   jPanel3.add(jLblC2);
                   JLabel jLblC3 =  new JLabel ();
                   jLblC3.setBounds(new Rectangle(25, 110, 60, 20));
                   jLblC3.setText("new");
                   jPanel3.add(jLblC3);
                   JLabel jLblC4 =  new JLabel ();
                   jLblC4.setBounds(new Rectangle(25, 130, 60, 20));
                   jLblC4.setText("new");
                   jPanel3.add(jLblC4);
                   JLabel jLblC5 =  new JLabel ();
                   jLblC5.setBounds(new Rectangle(25, 150, 60, 20));
                   jLblC5.setText("new");
                   jPanel3.add(jLblC5);
                   JLabel jLblC6 =  new JLabel ();
                   jLblC6.setBounds(new Rectangle(25, 170, 60, 20));
                   jLblC6.setText("new");
                   jPanel3.add(jLblC6);
                   JLabel jLblC7 =  new JLabel ();
                   jLblC7.setBounds(new Rectangle(25, 190, 60, 20));
                   jLblC7.setText("new");
                   jPanel3.add(jLblC7);
                   //jPanel3.add(getjLblEndTime(),null);
                   //jPanel3.add(getjTxtFEndTime(),null);
              return timePanel;
         private JPanel getrecurrencePanel(){
              if (recurrencePanel == null){
                   recurrencePanel=new JPanel();
                   //jPanel4.setBorder(new javax.swing.border.TitledBorder("Reccurrence"));
                   recurrencePanel.setLayout(null);
                   recurrencePanel.setBounds(0, 240, 700, 120);
                   recurrencePanel.add(getjLblRecurrence(),null);
                   recurrencePanel.add(getjChkBxSunday(),null);
                   recurrencePanel.add(getjLblSunday(),null);
                   recurrencePanel.add(getjChkBxMonday(),null);
                   recurrencePanel.add(getjLblMonday(),null);
                   recurrencePanel.add(getjChkBxTuesday(),null);
                   recurrencePanel.add(getjLblTuesday(),null);
                   recurrencePanel.add(getjChkBxWednesday(),null);
                   recurrencePanel.add(getjLblWednesday(),null);
                   recurrencePanel.add(getjChkBxThursday(),null);
                   recurrencePanel.add(getjLblThursday(),null);
                   recurrencePanel.add(getjChkBxFriday(),null);
                   recurrencePanel.add(getjLblFriday(),null);
                   recurrencePanel.add(getjChkBxSaturday(),null);
                   recurrencePanel.add(getjLblSaturday(),null);
              //jPanel4.add(new JSeparator(), BorderLayout.CENTER);
                   recurrencePanel.add(getjLblEndDate(),null);
                   recurrencePanel.add(getjTxtFEndDate(),null);
              return recurrencePanel;
         private JPanel getbuttonsPanel(){
              if (buttonsPanel == null){
                   buttonsPanel=new JPanel();
                   //jPanel5.setBorder(new javax.swing.border.TitledBorder("5"));
                   buttonsPanel.setLayout(null);
                   buttonsPanel.setBounds(0, 360, 700, 90);
                   buttonsPanel.add(getjBtnCancel(),null);
                   buttonsPanel.add(getjBtnSave(),null);
              return buttonsPanel;
         public JPanel getofficePanel(){
              if (officePanel == null){
                   officePanel=new JPanel();
                   officePanel.setLayout(null);
                   //jPanel6.setBorder(new javax.swing.border.TitledBorder("6"));
                   officePanel.setBounds(0, 70, 700, 80);
                   officePanel.add(getjCmbBxPanelOfficeType(),null);
                   officePanel.add(getjLblPanelOfficeLocation(),null);
                   officePanel.add(getjCmbBxPanelOfficeLocation(),null);
                   officePanel.add(getjLblPanelOfficeType(),null);
              return officePanel;
         private JPanel geteventsPanel(){
              if (eventsPanel == null){
                   eventsPanel=new JPanel();
                   eventsPanel.setLayout(null);
                   //jPanel7.setBorder(new javax.swing.border.TitledBorder("7"));
                   eventsPanel.setBounds(0, 120, 700, 150);
                   eventsPanel.add(getjLblEvent(),null);
                   eventsPanel.add(getjLblEventType(),null);
                   eventsPanel.add(getjLblEventStartTime(),null);
                   eventsPanel.add(getjLblEventEndTime(),null);
                  //jPanel7.add(new JSeparator(), new Dimension(180,10));
                   eventsPanel.add(getjCmbBxEventType(),null);
                   eventsPanel.add(getjCmbBxEventStartTimeHrs(),null);
                   eventsPanel.add(getjLblEventStartTimeColon(),null);
                   eventsPanel.add(getjCmbBxEventStartTimeMin(),null);
                   eventsPanel.add(getjCmbBxEventEndTimeHrs(),null);
                   eventsPanel.add(getjLblEventEndTimeColon(),null);
                   eventsPanel.add(getjCmbBxEventEndTimeMin(),null);
                   eventsPanel.add(getjBtnAdd(),null);
                  //jPanel7.add(getjCmbBxPanel6Location(),null);
              return eventsPanel;
          * mainPanel methods to get components
         private JLabel getjLblCalender()
              if(jLblCalender==null){
              jLblCalender =  new JLabel ();
              jLblCalender.setBounds(new Rectangle(25, 25, 60, 20));
              jLblCalender.setText("Calender");
              System.out.println(jLblCalender.getBounds());
              //jLblCalender.setBounds(20, 20, 100, 16);
              return jLblCalender;
         public JComboBox getjCmbBxCalender(){
              if (jCmbBxCalender == null){
         calender = new String[] {"Office","Counselor"};
          jCmbBxCalender = new JComboBox (calender);
          jCmbBxCalender.setBounds(new Rectangle (90,25,140,20));
              return jCmbBxCalender;
         private JRadioButton getjRdBttnDay(){
               if(jRBttnDay==null){
                    jRBttnDay=new JRadioButton();
                    jRBttnDay.setBounds(new Rectangle(350,25, 60, 20));
                    jRBttnDay.setText("Day");
                    //jRBttnOffice.addItemListener( rhandler );
              return jRBttnDay;
          private JRadioButton getjRdBttnEvent(){
               if(jRBttnEvent==null){
                    jRBttnEvent=new JRadioButton();
                    jRBttnEvent.setBounds(new Rectangle(350, 50, 60, 20));
                    jRBttnEvent.setText("Event");
                    //jRBttnEvent.addItemListener( rhandler );
              return jRBttnEvent;
               * counselorPanel methods to get components
          private JLabel getjLblCounselor()
                   if(jLblCounselor==null){
                   jLblCounselor =  new JLabel ();
                   jLblCounselor.setBounds(new Rectangle(25,25,60,20));
                   jLblCounselor.setText("Counselor");
                   //jLblCalender.setBounds(0, 0, 33, 16);
                   return jLblCounselor;
              private JLabel getjLblLocation()
                   if(jLblLocation==null){
                   jLblLocation =  new JLabel ();
                   jLblLocation.setBounds(new Rectangle(25,60,60,20));
                   jLblLocation.setText("Location");
                   //jLblCalender.setBounds(0, 0, 33, 16);
                   return jLblLocation;
              private JLabel getjLblType()
                   if(jLblType==null){
                   jLblType =  new JLabel ();
                   jLblType.setBounds(new Rectangle(25,95,60,20));
                   jLblType.setText("Type");
                   //jLblCalender.setBounds(0, 0, 33, 16);
                   return jLblType;
              private JLabel getjLblType1()
                   if(jLblType1==null){
                   jLblType1 =  new JLabel ();
                   jLblType1.setBounds(new Rectangle(350, 25, 40, 20));
                   jLblType1.setText("Type  :");
                   //jLblCalender.setBounds(0, 0, 33, 16);
                   return jLblType1;
              public JComboBox getjCmbBxCounselor(){
                   if (jCmbBxCounselor == null){
              counselor = new String[] {"John","Jason","Sam"};
               jCmbBxCounselor = new JComboBox (counselor);
               jCmbBxCounselor.setBounds(new Rectangle (90,25,140,20));
                   return jCmbBxCounselor;
              public JComboBox getjCmbBxLocation(){
                   if (jCmbBxLocation == null){
                        location = new String[] {"Oakland","Sanfrancisco"};
                        jCmbBxLocation= new JComboBox(location);
                        jCmbBxLocation.setBounds(new Rectangle (90,60,140,20));
                   return jCmbBxLocation;
              public JComboBox getjCmbBxType(){
                   if (jCmbBxType == null){
              type = new String[] {"Regular","Non Regular"};
               jCmbBxType = new JComboBox (type);
               jCmbBxType.setBounds(new Rectangle (90,95,140,20));
                   return jCmbBxType;
              private JRadioButton getjRdBttnOffice(){
                    if(jRBttnOffice==null){
                         jRBttnOffice=new JRadioButton();
                         jRBttnOffice.setBounds(new Rectangle(490, 25, 60, 20));
                         jRBttnOffice.setText("Office");
                         //jRBttnOffice.addItemListener( rhandler );
                   return jRBttnOffice;
               private JRadioButton getjRdBttnCounselor(){
                    if(jRBttnCounselor==null){
                         jRBttnCounselor=new JRadioButton();
                         jRBttnCounselor.setBounds(new Rectangle(400, 25, 90, 20));
                         jRBttnCounselor.setText("Counselor");
                         //jRBttnCounselor.addItemListener( rhandler );
                   return jRBttnCounselor;
                    * timePanel methods to get components
               private JLabel getjLblStartDate()
                        if(jLblStartDate==null){
                             jLblStartDate =  new JLabel ();
                             jLblStartDate.setBounds(new Rectangle(25,25,60,20));
                             jLblStartDate.setText("Start Date ");
                        //jLblCalender.setBounds(0, 0, 33, 16);
                        return jLblStartDate;
                   private JLabel getjLblStartTime()
                        if(jLblStartTime==null){
                             jLblStartTime =  new JLabel ();
                             jLblStartTime.setBounds(new Rectangle(350,25,70,20));
                             jLblStartTime.setText("Start Time ");
                        //jLblCalender.setBounds(0, 0, 33, 16);
                        return jLblStartTime;
                   private JLabel getjLblEndTime()
                        if(jLblEndTime==null){
                             jLblEndTime =  new JLabel ();
                             jLblEndTime.setBounds(new Rectangle(350,60,70,20));
                             jLblEndTime.setText("End Time ");
                        //jLblCalender.setBounds(0, 0, 33, 16);
                        return jLblEndTime;
                   private JTextField getjTxtFStartDate() {
                        if (jTxtFStartDate == null) {
                             jTxtFStartDate = new JTextField();
                             //jTxtFRefNum.setBounds(new Rectangle(86, 51, 109, 20));
                             jTxtFStartDate.setBounds(new Rectangle(90,25,140,20));
                             jTxtFStartDate.setText("Start Date");
                        return jTxtFStartDate;
                   private JComboBox getjCmbBxStartTimeMin(){
                        if (jCmbBxStartTimeMin == null){
                   counselor = new String[] {"00","02","03","04"};
                    jCmbBxStartTimeMin = new JComboBox (counselor);
                    jCmbBxStartTimeMin.setBounds(new Rectangle (490,25,40,20));
                        return jCmbBxStartTimeMin;
                   private JComboBox getjCmbBxStartTimeHrs(){
                        if (jCmbBxStartTimeHrs == null){
                   counselor = new String[] {"00","02","03","04"};
                    jCmbBxStartTimeHrs = new JComboBox (counselor);
                    jCmbBxStartTimeHrs.setBounds(new Rectangle (425, 25,40,20));
                        return jCmbBxStartTimeHrs;
                   private JLabel getjLblEndTimeColon()
                        if(jLblEndTimeColon==null){
                             jLblEndTimeColon =  new JLabel ();
                             jLblEndTimeColon.setBounds(new Rectangle(475,60,5,20));
                             jLblEndTimeColon.setText(":");
                        //jLblCalender.setBounds(0, 0, 33, 16);
                        return jLblEndTimeColon;
                   private JLabel getjLblStartTimeColon()
                        if(jLblStartTimeColon==null){
                             jLblStartTimeColon =  new JLabel ();
                             jLblStartTimeColon.setBounds(new Rectangle(475,25,5,20));
                             jLblStartTimeColon.setText(":");
                        //jLblCalender.setBounds(0, 0, 33, 16);
                        return jLblStartTimeColon;
                   private JComboBox getjCmbBxEndTimeMin(){
                        if (jCmbBxEndTimeMin == null){
                   counselor = new String[] {"00","02","03","04"};
                    jCmbBxEndTimeMin = new JComboBox (counselor);
                    jCmbBxEndTimeMin.setBounds(new Rectangle (490,60,40,20));
                        return jCmbBxEndTimeMin;
                   private JComboBox getjCmbBxEndTimeHrs(){
                        if (jCmbBxEndTimeHrs == null){
                   counselor = new String[] {"00","02","03","04"};
                    jCmbBxEndTimeHrs = new JComboBox (counselor);
                    jCmbBxEndTimeHrs.setBounds(new Rectangle (425,60,40,20));
                        return jCmbBxEndTimeHrs;
                    * recurrencePanel methods to get components
                   private JLabel getjLblSunday()
                        if(jLblSunday==null){
                             jLblSunday =  new JLabel ();
                             jLblSunday.setBounds(new Rectangle(125, 50, 50, 20));
                             jLblSunday.setText("Sunday");
                        //jLblCalender.setBounds(0, 0, 33, 16);
                        return jLblSunday;
                   private JLabel getjLblMonday()
                        if(jLblMonday==null){
                             jLblMonday =  new JLabel ();
                             jLblMonday.setBounds(new Rectangle(205,50,50,20));
                             jLblMonday.setText("Monday");
                        //jLblCalender.setBounds(0, 0, 33, 16);
                        return jLblMonday;
                   private JLabel getjLblTuesday()
                        if(jLblTuesday==null){
                             jLblTuesday =  new JLabel ();
                             jLblTuesday.setBounds(new Rectangle(285,50,50,20));
                             jLblTuesday.setText("Tuesday");
                        //jLblCalender.setBounds(0, 0, 33, 16);
                        return jLblTuesday;
                   private JLabel getjLblWednesday()
                        if(jLblWednesday==null){
                             jLblWednesday =  new JLabel ();
                             jLblWednesday.setBounds(new Rectangle(370, 50,70,20));
                             jLblWednesday.setText("Wednesday");
                        //jLblCalender.setBounds(0, 0, 33, 16);
                        return jLblWednesday;
                   private JLabel getjLblThursday()
                        if(jLblThursday==null){
                             jLblThursday =  new JLabel ();
                             jLblThursday.setBounds(new Rectangle(475,50,60,20));
                             jLblThursday.setText("Thursday");
                        //jLblCalender.setBounds(0, 0, 33, 16);
                        return jLblThursday;
                   private JLabel getjLblFriday()
                        if(jLblFriday==null){
                             jLblFriday =  new JLabel ();
                             jLblFriday.setBounds(new Rectangle(565,50,40,20));
                             jLblFriday.setText("Friday");
                        //jLblCalender.setBounds(0, 0, 33, 16);
                        return jLblFriday;
                   private JLabel getjLblSaturday()
                        if(jLblSaturday==null){
                             jLblSaturday =  new JLabel ();
                             jLblSaturday.setBounds(new Rectangle(635,50,60,20));
                             jLblSaturday.setText("Saturday");
                        //jLblCalender.setBounds(0, 0, 33, 16);
                        return jLblSaturday;
                   private JCheckBox getjChkBxSunday() {
                        if (jChkBxSunday == null) {
                             jChkBxSunday = new JCheckBox ("Sunday",false);
                             jChkBxSunday.setBounds(new Rectangle(100,50,20,20));
                        return jChkBxSunday;
                    private JCheckBox getjChkBxMonday() {
                             if (jChkBxMonday == null) {
                                  jChkBxMonday = new JCheckBox ("Monday",false);
                                  jChkBxMonday.setBounds(new Rectangle(180,50,20,20));
                             return jChkBxMonday;
                    private JCheckBox getjChkBxTuesday() {
                             if (jChkBxTuesday == null) {
                                  jChkBxTuesday = new JCheckBox ("Tuesday",false);
                                  jChkBxTuesday.setBounds(new Rectangle(260,50,20,20));
                             return jChkBxTuesday;
                    private JCheckBox getjChkBxWednesday() {
                             if (jChkBxWednesday == null) {
                                  jChkBxWednesday = new JCheckBox ("Wedneday",false);
                                  jChkBxWednesday.setBounds(new Rectangle(345,50,20,20));
                             return jChkBxWednesday;
                    private JCheckBox getjChkBxThursday() {
                             if (jChkBxThursday == null) {
                                  jChkBxThursday = new JCheckBox ("Thursday",false);
                                  jChkBxThursday.setBounds(new Rectangle(450,50,20,20));
                             return jChkBxThursday;
                    private JCheckBox getjChkBxFriday() {
                             if (jChkBxFriday == null) {
                                  jChkBxFriday = new JCheckBox ("Friday",false);
                                  jChkBxFriday.setBounds(new Rectangle(540,50,20,20));
                             return jChkBxFriday;
                    private JCheckBox getjChkBxSaturday() {
                             if (jChkBxSaturday == null) {
                                  jChkBxSaturday = new JCheckBox ("Saturday",false);
                                  jChkBxSaturday.setBounds(new Rectangle(610,50,20,20));
                             return jChkBxSaturday;
                    private JLabel getjLblEndDate()
                             if(jLblEndDate==null){
                                  jLblEndDate =  new JLabel ();
                                  jLblEndDate.setBounds(new Rectangle(25,85,60,20));
                                  jLblEndDate.setText("End Date");
                             //jLblCalender.setBounds(0, 0, 33, 16);
                             return jLblEndDate;
                    private JTextField getjTxtFEndDate() {
                             if (jTxtFEndDate == null) {
                                  jTxtFEndDate = new JTextField();
                                  //jTxtFRefNum.setBounds(new Rectangle(86, 51, 109, 20));
                                  jTxtFEndDate.setBounds(new Rectangle(90,85,140,20));
                                  jTxtFEndDate.setText("End Date");
                             return jTxtFEndDate;
                    private JLabel getjLblRecurrence()
                             if(jLblRecurrence==null){
                                  jLblRecurrence =  new JLabel ();
                                  jLblRecurrence.setBounds(new Rectangle(25,25,80,20));
                                  jLblRecurrence.setText("Recurrence ");
                             //jLblCalender.setBounds(0, 0, 33, 16);
                             return jLblRecurrence;
                         * buttonsPanel methods to get components
                    private JButton getjBtnCancel(){
                         if(jBttnCancel==null){
                              jBttnCancel=new JButton();
                              jBttnCancel.setBounds(new Rectangle(510,25,80,20));
                              jBttnCancel.setText("Cancel");
                        return jBttnCancel;
                    private JButton getjBtnSave(){
                         if(jBttnSave==null){
                              jBttnSave=new JButton();
                              jBttnSave.setBounds(new Rectangle(600,25,80,20));
                              jBttnSave.setText("Save");
                        return jBttnSave;
                         * OfficePanel methods to get components
                    private JLabel getjLblPanelOfficeType()
                             if(jLblPanelOfficeType==null){
                                  jLblPanelOfficeType =  new JLabel ();
                                  jLblPanelOfficeType.setBounds(new Rectangle(25,25,60,20));
                                  jLblPanelOfficeType.setText("Type");
                             //jLblCalender.setBounds(0, 0, 33, 16);
                             return jLblPanelOfficeType;
                        private JLabel getjLblPanelOfficeLocation()
                             if(jLblPanelOfficeLocation==null){
                                  jLblPanelOfficeLocation =  new JLabel ();
                                  jLblPanelOfficeLocation.setBounds(new Rectangle(25,60,60,20));
                                  jLblPanelOfficeLocation.setText("Location");
                             //jLblCalender.setBounds(0, 0, 33, 16);
                             return jLblPanelOfficeLocation;
                        public JComboBox getjCmbBxPanelOfficeLocation(){
                             if (jCmbBxPanelOfficeLocation == null){
                                  String[] Officelocation = new String[] {"OakLand","San Fransisco"};
                        jCmbBxPanelOfficeLocation = new JComboBox (Officelocation);;
                        jCmbBxPanelOfficeLocation.setBounds(new Rectangle (90,60,140,20));
                             return jCmbBxPanelOfficeLocation;
                        private JComboBox getjCmbBxPanelOfficeType(){
                             if (jCmbBxPanelOfficeType == null){
                                  String [] Officetype = new String[] {"Regular","OnCall"};
                         jCmbBxPanelOfficeType = new JComboBox (Officetype);
                         jCmbBxPanelOfficeType.setBounds(new Rectangle (90,25,140,20));
                             return jCmbBxPanelOfficeType;
                         * eventsPanel methods to get components
                        private JComboBox getjCmbBxEventType(){
                             if (jCmbBxEventType == null){
                        counselor = new String[] {"John","Jason"};
                         jCmbBxEventType = new JComboBox (counselor);
                         jCmbBxEventType.setBounds(new Rectangle (120,90,130,20));
                             return jCmbBxEventType;
                        private JComboBox getjCmbBxEventStartTimeHrs(){
                             if (jCmbBxEventStartTimeHrs == null){
                        counselor = new String[] {"12","00"};
                         jCmbBxEventStartTimeHrs = new JComboBox (counselor);
                         jCmbBxEventStartTimeHrs.setBounds(new Rectangle (290,90,40,20));
                             return jCmbBxEventStartTimeHrs;
                        private JComboBox getjCmbBxEventStartTimeMin(){
                             if (jCmbBxEventStartTimeMin == null){
                        counselor = new String[] {"00","02","03","04"};
                         jCmbBxEventStartTimeMin = new JComboBox (counselor);
                         jCmbBxEventStartTimeMin.setBounds(new Rectangle (355,90,40,20));
                             return jCmbBxEventStartTimeMin;
                        private JComboBox getjCmbBxEventEndTimeHrs(){
                             if (jCmbBxEventEndTimeHrs == null){
                        counselor = new String[] {"00","02","03","04"};
                         jCmbBxEventEndTimeHrs = new JComboBox (counselor);
                         jCmbBxEventEndTimeHrs.setBounds(new Rectangle (470,90,40,20));
                             return jCmbBxEventEndTimeHrs;
                        private JComboBox getjCmbBxEventEndTimeMin(){
                             if (jCmbBxEventEndTimeMin == null){
                        counselor = new String[] {"John","Jason","Sam"};
                         jCmbBxEventEndTimeMin = new JComboBox (counselor);
                         jCmbBxEventEndTimeMin.setBounds(new Rectangle (535,90,40,20));
                             return jCmbBxEventEndTimeMin;
                        private JLabel getjLblEventType()
                             if(jLblEventType==null){
                             jLblEventType =  new JLabel ();
                             jLblEventType.setBounds(new Rectangle(150, 60,60,20));
                             jLblEventType.setText("Type");
                             //System.out.println(jLblCalender.getBounds());
                             //jLblCalender.setBounds(20, 20, 100, 16);
                             return jLblEventType;
                        private JLabel getjLblEvent()
                             if(jLblEvents==null){
                             jLblEvents =  new JLabel ();
                             jLblEvents.setBounds(new Rectangle(325, 25, 60, 20));
                             jLblEvents.setText("Events");
                             //System.out.println(jLblCalender.getBounds());
                             //jLblCalender.setBounds(20, 20, 100, 16);
                             return jLblEvents;
                        private JLabel getjLblEventStartTime()
                             if(jLblEventStartTime==null){
                             jLblEventStartTime =  new JLabel ();
                             jLblEventStartTime.setBounds(new Rectangle(310, 60,60,20));
                             jLblEventStartTime.setText("Start Time");
                             //System.out.println(jLblCalender.getBounds());
                             //jLblCalender.setBounds(20, 20, 100, 16);
                             return jLblEventStartTime;
                        private JLabel getjLblEventEndTime()
                             if(jLblEventEndTime==null){
                             jLblEventEndTime =  new JLabel ();
                             jLblEventEndTime.setBounds(new Rectangle(500, 60,60,20));
                             jLblEventEndTime.setText("End Time");
                             //System.out.println(jLblCalender.getBounds());
                             //jLblCalender.setBounds(20, 20, 100, 16);
                             return jLblEventEndTime;
                        private JLabel getjLblEventStartTimeColon()
                             if(jLblEventStartTimeColon==null){
                                  jLblEventStartTimeColon =  new JLabel ();
                                  jLblEventStartTimeColon.setBounds(new Rectangle(340,90,5,20));
                                  jLblEventStartTimeColon.setText(":");
                             //jLblCalender.setBounds(0, 0, 33, 16);
                             return jLblEventStartTimeColon;
                        private JLabel getjLblEventEndTimeColon()
                             if(jLblEventEndTimeColon==null){
                                  jLblEventEndTimeColon =  new JLabel ();
                                  jLblEventEndTimeColon.setBounds(new Rectangle(520,90,5,20));
                                  jLblEventEndTimeColon.setText(":");
                             //jLblCalender.setBounds(0, 0, 33, 16);
                             return jLblEventEndTimeColon;
                         private JButton getjBtnAdd(){
                              if(jBttnAdd==null){
                                   jBttnAdd=new JButton();
                                   jBttnAdd.setBounds(new Rectangle(25,115,80,20));
                                   jBttnAdd.setText("Add");
                             return jBttnAdd;
    //                     Action Listeners
                                  public void addCmbBoxCalenderListener (ItemListener eve){
                                  if (this.jCmbBxCalender != null){
                                       jCmbBxCalender.addItemListener(eve);
                             }Here is my controller code:
    private class JCmbBxCalenderListener implements ActionListener {
                   public void actionPerformed( ActionEvent event ){
                         try{
                              if(((JComboBox) event.getSource()).getSelectedItem().equals("Office Calender")){
                                   //calenderAdmin_View.jContentPane.revalidate();
                                   calenderAdmin_View.jContentPane.remove(calenderAdmin_View.getcounselorPanel());
                                   calenderAdmin_View.getcounselorPanel().setVisible(false);
                                       calenderAdmin_View.jContentPane.add(calenderAdmin_View.getofficePanel(),1);
                                   calenderAdmin_View.getofficePanel().setVisible(true);
                                   calenderAdmin_View.jContentPane.validate();
                              else
                                   if(((JComboBox) event.getSource()).getSelectedItem().equals("Counselor Calender"))
                                        //calenderAdmin_View.jContentPane.revalidate();
                                        calenderAdmin_View.jContentPane.remove(calenderAdmin_View.getofficePanel());
                                        calenderAdmin_View.getofficePanel().setVisible(false);
                                        calenderAdmin_View.jCo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

  • Printing JTable with DefaultTableCellRenderer (or JLabel's)

    Hi there,
    I am trying to print a JTable by having it implement the Printable interface. It works, but it works only because I use the string values from the renderers of the cells. This works fine if its just simple left alligned strings.
    But when you are using formatted text strings for instance (in a DefaultTableCellRenderer extension) or something that represents a boolean (a checkbox), it doesn't look very good. Bad actually. I tried to use the print method on the renderer or cast them first to a JComponent or JLabel and then use the print method. No success so far. Can anybody help me? I am quit desperate right now.
    Kind regards,
    Ren�

    Yes I can. I took the print method from the class in which I implemented it (the JTable is a member of that particular class):
    * Implementing the Printable interface.
    * For printing the same font is used as is used on the screen.
    * So, no special print font is used or can be choosen at this
    * point. Also the font size is taken from the table on screen.
    * The title font is twice the font size of the normal font, but
    * bold. The column headers have the same font as the normal font
    * but also bold like the title.
    * The height we'll be using for a line of text will be 1.5 times
    * the average height in this font, with a minimum of 10.
    * The title font, the table header font and the table content font
    * are all the same (unlike the table) and based on the table font.
    * The table header font is not used.
    * If the table does not fit on paper, one could adjust the orientation
    * of the paper in the paper dialog, or adjust the distance bewtween
    * the columns on the screen as the column width on the screen is
    * taken to the paper.
    public int print(Graphics pg, PageFormat pageFormat, int pageIndex) throws PrinterException {
    if (pageIndex >= m_maxNumPage) {
    return NO_SUCH_PAGE;
    // This is for anti aliasing.
    Graphics2D g2d = null;
    if (pg instanceof Graphics2D) {
    g2d = (Graphics2D) pg;
    g2d.addRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
    g2d.addRenderingHints(new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    pg.translate((int) pageFormat.getImageableX(), (int) pageFormat.getImageableY());
    int wPage = (int) pageFormat.getImageableWidth();
    int hPage = (int) pageFormat.getImageableHeight();
    // This will make sure no printing is
    // done outside the designated area.
    pg.setClip(0, 0, wPage, hPage);
    // Forget this: its a test (works fine though).
    //table.print(g2d);
    //if (true)
    // return PAGE_EXISTS;
    int y = 0;
    // Make the title font size twice the size of the regular font size.
    pg.setFont(this.table.getFont().deriveFont(Font.BOLD, (this.table.getFont().getSize() * 2)));
    pg.setColor(Color.black);
    FontMetrics fm = pg.getFontMetrics();
    y += fm.getAscent();
    // Draw the title, the date and the page number.
    pg.drawString(pageTitle + " " + DateFormat.getDateInstance(DateFormat.MEDIUM, this.locale).format(new Date(System.currentTimeMillis())) + " (" + (pageIndex + 1) + ") ", 0, y);
    //          pg.drawString(pageTitle + " " + DateFormat.getDateInstance().format(new Date(System.currentTimeMillis())) + " (" + (pageIndex + 1) + ") ", 0, y);
    y += 20; // space between title and table headers
    // The font for the table headers.
    Font headerFont = this.table.getTableHeader().getFont();
    pg.setFont(headerFont);
    fm = pg.getFontMetrics();
    TableColumnModel colModel = this.table.getColumnModel();
    int nColumns = colModel.getColumnCount();
    int x[] = new int[nColumns];
    x[0] = 0;
    int h = fm.getAscent();
    // Add ascent of header font because of baseline positioning.
    y += h;
    int nRow, nCol;
    // Draw the COLUMN HEADERS.
    for (nCol = 0; nCol < nColumns; nCol++) {
    TableColumn tk = colModel.getColumn(nCol);
    int width = tk.getWidth();
    String title = (String) tk.getIdentifier();
    // The x offset for each column stored.
    if (nCol + 1 < nColumns) {
    x[nCol + 1] = x[nCol] + width;
    // If this is not the last column header, calculated
    // how many characters can be printed, based on the
    // width of the column being printed.
    if ((nCol < (nColumns - 1)) && title.length() > 0) {
    //if (x[nCol] + width <= wPage) {
    for (int i = title.length(); i >= 0; i--) {
    if ((fm.stringWidth(title.substring(0, i))) <= width) {
    // Adjust the colum header for the space available (the width).
    title = title.substring(0, i);
    break;
    // Draw the column header.
    pg.drawString(title, x[nCol], y);
    pg.setFont(this.table.getFont());
    fm = pg.getFontMetrics();
    int header = y;
    // Gets the standard height of a line of text in this font.
    // This is the distance between the baseline of adjacent lines of text.
    // It is the sum of the leading + ascent + descent. There is no guarantee
    // that lines of text spaced at this distance are disjoint; such lines may
    // overlap if some characters overshoot either the standard ascent or the
    // standard descent metric.
    h = fm.getHeight();
    // Calculate the ACTUAL height we'll be using for a line of text.
    // That would be 1.5 times the average height, with a minimum of 10.
    // Actually, normally, the average height should suffice. But we're
    // not taking any risks here.
    int rowHeight = Math.max((int) (h * 1.5), 10);
    // Calculate how many rows fit on a page.
    int rowPerPage = (hPage - header) / rowHeight;
    m_maxNumPage = Math.max((int) Math.ceil(this.table.getRowCount() / (double) rowPerPage), 1);
    int iniRow = pageIndex * rowPerPage;
    int endRow = Math.min(this.table.getRowCount(), iniRow + rowPerPage);
    String cell = null;
    // Draw every ROW.
    for (nRow = iniRow; nRow < endRow; nRow++) {
    y += rowHeight;
    // Draw each CELL in each ROW.
    for (nCol = 0; nCol < nColumns; nCol++) {
    cell = null;
    int col = this.table.getColumnModel().getColumn(nCol).getModelIndex();
    // Get the cell object. This is the object that needs to be printed.
    Object object = model.getValueAt(nRow, col);
    // RENDERING FOR PRINTING! Here is determined for the printing how the rendering is done.
    // If a special renderer had been set an attempt is made to use that renderer (e.g. get the text).
    // If that is not possible, simple rendering: the toString() value.
    // BE AWARE! The format for numbers, booleans etc. might require better code.
    if (table.getColumnModel().getColumn(nCol).getCellRenderer() != null) {
    if (table.getColumnModel().getColumn(nCol).getCellRenderer().getTableCellRendererComponent(table, object, false, false, nRow, nCol) != null) {
    if (table.getColumnModel().getColumn(nCol).getCellRenderer().getTableCellRendererComponent(table, object, false, false, nRow, nCol) instanceof JLabel) {
    cell = ((JLabel) table.getColumnModel().getColumn(nCol).getCellRenderer().getTableCellRendererComponent(table, object, false, false, nRow, nCol)).getText();
    //table.getCellRenderer(0, nCol).getTableCellRendererComponent(table, object, false, false, 0, nCol).paint(g2d);
    // Object fiets = table.getCellRenderer(0, nCol).getTableCellRendererComponent(table, object, false, false, 0, nCol);
    // if (fiets instanceof DefaultTableCellRenderer) {
    //      System.out.println("DefaultTableCellRenderer!" + nCol);
    //      ((DefaultTableCellRenderer) fiets).print(pg);
    // If the object is a Boolean, print an "X" or an "O".
    if (object instanceof Boolean) {
    cell = (((Boolean) object).equals(new Boolean(true)) ? "X" : "O");
    // Still don't know how to print it? Use the object's toString() method.
    // This is probably used in most cases anyway!
    if (cell == null && object != null) {
    //cell = object.toString();
    if (cell == null) {
    cell = "";
    // If this is not the last column, calculated how many
    // characters can be printed, based on the width of
    // the column being printed.
    if ((nCol < (nColumns - 1)) && cell.length() > 0) {
    int width = colModel.getColumn(nCol).getWidth();
    for (int i = cell.length(); i >= 0; i--) {
    if ((fm.stringWidth(cell.substring(0, i))) <= width) {
    // Adjust the size.
    cell = cell.substring(0, i);
    break;
    // Print the cell.
    pg.drawString(cell, x[nCol], y);
    System.gc();
    return PAGE_EXISTS;
    }

  • 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.

  • JLabel placement help

    I am making a java game, and i have managed to put two squares on my panel. The first sqaure is the player which moves up and down and the other square/s appear from the right and then move to the left (point of the game being the player should avoid on coming blocks).
    like I said I have put these blocks on the screen but I cant place them where I want.
    Here is the class that creates the "player" (the on coming blocks is in another class with the same code except the ive set the color differnetly).
    public class Player extends JPanel{
         int row = 20;
         int col = 20;
         Player()
              JLabel[][] jPan = new JLabel[row][col];
              this.setBackground(Color.GREEN);
              for (int x = 0 ; x < row; x++)
                   for (int y = 0; y < col; y++)
                       jPan[x][y] = new JLabel();
                       this.add(jPan[x][y]);
                       this.setPreferredSize(new Dimension(20,20));                  
    }and this goes into the constructor in another class
    public class Game extends JPanel {
    private Player player = new Player();
    private Blocks block = new Blocks();
    Game()
        this.add(player, BorderLayout.PAGER_START);
        this.add(block, BorderLayout.PAGE_START);
        this.setBackground(Color.BLACK);
        this.setPreferredSize(new Dimension(500,500));
    }So can any one show me how to place my squares where I want them?
    Also where is the best place to put the keylistener for the player, inside the same class or in another class?

    When you want to place your "item" you shoud use one of suitable Layout Manager. Well actually you can use a lot of them . If you still have any problem you can use NetBeans in Free Design mode.
    This lauout enables you to lay out your form using visual guidelines that automatically suggest optimal alignment and spacing of components

  • FlowLayout and Jlabels and Jbuttons,  Help!!!!!

    Ok, I have an Assignment using the FlowLayout only!!. I have been readin all the tutorials and documentation regarding the FlowLayout. Yet it seems I have a problem. Within my prrogram I am to position the buttons on the right and postion the text on the left.
    My question is: Is there a way to postion each component separtely using FlowLayout. Can yoo position the Jlabels to the left and the JButtons to the right?
    I know other layouts would be easier but our proffessor wants us to use the flowlayout for this assignment.
    Here is my code
    import javax.swing.*;
    import java.awt.*;
    import java.awt.FlowLayout;
    import java.awt.Font;
                   public class VideoStore extends JFrame {
                        JButton b1, b2, b3;
                        JLabel movie1,movie2,movie3,header;
                   public VideoStore (String title) {
                        super (title);
                        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        FlowLayout video = new FlowLayout(FlowLayout.LEFT);
                       setLayout(video);
                        header = new JLabel("CCAC VideoStore");
                        header.setFont(new Font("Times New Roman", Font.BOLD, 24));
                       add(header);
                       {movie1= new JLabel("Johnson Family Vacation");
                       movie1.setFont(new Font("Courier New", Font.BOLD, 14));
                        add(movie1);
                        b1= new JButton("Buy");
                        video.setAlignment(FlowLayout.RIGHT);
                        add(b1);}
                        movie2= new JLabel("PitchBlack");
                            movie2.setFont(new Font("Courier New", Font.BOLD, 14));
                       add(movie2);
                        b2 = new JButton ("Buy");
                        add(b2);
                        movie3= new JLabel ("Meet The Fockers");
                       movie3.setFont(new Font("Courier New", Font.BOLD, 14));
                       add(movie3);
                        b3 = new JButton ("Buy");
                        add(b3);
                   }Edited by: ConfusedNewb on Apr 20, 2010 8:10 AM

    ConfusedNewb wrote:
    Sorry.Requirements are: All of the "Buy" JButtons need aligned to the right and all of the JLabels need aligned to the left. There are 3 movie Jlabels and 3 jbuttons. I just cant get them to align without using the spacing trick. Everything has to fit in one window.This should be layed out with 2 JPanels, one for the Labels and one for the Buttons. Since FlowLayout will lay the 2 JPanels side by side, you will get the separation that you need. You just need to justify the Label and Button Panels appropriately and make the outer container and Panels appropriate widths to allow the layout to function as you need.

  • In Pages 5.1 how do I change the default spacing after a paragraph? I used to be able to do this with the inspector. I no longer see the option.

    In pages 5.1 I was wondering how to change the line spacing after a paragraph.

    This is from the online Pages Help . You have the option to the Help in your Pages Help menu
    Adjust line spacing
    You can adjust the spacing between lines in a paragraph, and change the amount of space before or after a paragraph.
    Click in the paragraph whose spacing you want to change, or select one or more paragraphs.
    In the Text pane of the Format inspector, click Style.
    Click the disclosure triangle next to Spacing, then choose an option from the pop-up menu:
    Lines: Choose when the distance between ascenders (parts of letters that extend to the top of the line) and descenders (parts of letters that extend below the line) should stay the same. The space between lines is proportional to the font size.
    At least: Choose when the distance between lines should remain fixed (but not to overlap if the text gets large).The distance from one line to the next will never be less than the value you set, but it may be larger for larger fonts to prevent overlapping text lines.
    Exactly: The distance between the baselines.
    Between: The value you set increases the space between the lines, instead of increasing the height of the lines. By contrast, double-spacing doubles the height of each line.
    Click the arrows next to the spacing field to set the amount of space for the option you chose.
    To adjust the amount of space before and after the selected paragraph, click the arrows for Before Paragraph and After Paragraph

  • Non-English character not showing up in JLabel correctly

    In my program there is a JLabel that displays Chinese characters in several sizes of fonts, it was displaying all of them correctly until my program grew larger and takes longer to initialize, now it is only displaying some sizes of fonts correctly while displaying others as rectangles. Since my program is too large to be imported here, I am trying to demo the problem in a smaller program, but in this smaller program, all sizes of fonts showed up correctly, here it is :
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class Java_Test extends JPanel
      static int Total=9000;
      JComboBox ComboBox_Array[]=new JComboBox[Total];
      Font Times_New_Roman_15_Font=new Font("Times New Roman",0,15);
      int Small_Chinese_Font_Size=3;
      String Software_Info_Chinese_Text="<Html><Table Width=100% Border=0 Cellpadding=2 Cellspacing=3><Tr><Td Align=Center><Font Size=6 Color=#3737FF>[ \u4EA7\u54C1\u7BA1\u7406 ] </Font></Td></Tr>"+
                                               "<Tr><Td Align=Center><Font Size=5 Color=green>\u5E2E\u52A9\u4F60\u7BA1\u7406\u4EA7\u54C1, \u5408\u540C, \u53CA\u5176\u5B83\u4FE1\u606F :</Font></Td></Tr>"+
                                               "<Tr><Td><Font Size="+Small_Chinese_Font_Size+" Color=#2255BB>"+
                                                 "<li>\u8F93\u5165, \u7EF4\u62A4\u548C\u6253\u5370\u8BE6\u7EC6\u4EA7\u54C1\u53CA\u4F9B\u8D27\u5546\u4FE1\u606F<Br>"+
                                                 "<li>\u5730\u5740\u548C\u5907\u6CE8\u4FE1\u606F\u53EF\u7528\u591A\u79CD\u8BED\u8A00\u8F93\u5165<Br>"+
                                               "</Font></Td></Tr>"+
                                               "</Table></Html>";
      Java_Test()
        for (int i=0;i<Total;i++) ComboBox_Array=new JComboBox();
    JLabel A_Non_English_Label=new JLabel(Software_Info_Chinese_Text);
    A_Non_English_Label.setFont(Times_New_Roman_15_Font);
    A_Non_English_Label.setForeground(Color.BLUE);
    add(A_Non_English_Label);
    setPreferredSize(new Dimension(500,200));
    static void Out(String message) { System.out.println(message); }
    public static void main(String[] args)
    final Java_Test demo=new Java_Test();
    Dimension Screen_Size=Toolkit.getDefaultToolkit().getScreenSize();
    final JFrame frame=new JFrame("Java Test");
    frame.add(demo);
    frame.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e) { System.exit(0); }
    public void windowDeiconified(WindowEvent e) { demo.repaint(); }
    public void windowGainedFocus(WindowEvent e) { demo.repaint(); }
    public void windowOpening(WindowEvent e) { demo.repaint(); }
    public void windowResized(WindowEvent e) { demo.repaint(); }
    public void windowStateChanged(WindowEvent e) { demo.repaint(); }
    frame.pack();
    frame.setBounds((Screen_Size.width-demo.getWidth())/2,(Screen_Size.height-demo.getHeight())/2-10,demo.getWidth(),demo.getHeight()+38);
    frame.setVisible(true);
    As you can see, in this smaller program I'm trying to create a Total of 9000 objects to simulate lots of memory use, but to no avail. It is still displaying all sizes of fonts correctly.
    In my large program if I change html font from size 3 to size 5, it will display correctly, it seems that for certain sizes it can't display properly when the program gets too large and complicated, not because I don't have the fonts, but because of the complexity of my program. I wonder if anyone else has similar problems, and how to solve it ?
    Frank                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I've just made a breakthrough, the large program will work correctly if I comment out : A_Non_English_Label.setFont(Times_New_Roman_15_Font);
    But then the font doesn't look the way I wanted it to be.
    So I changed it to the following :
    ================================================
    Font Courier_New_15_Font=new Font("Courier New",0,15);
    A_Non_English_Label.setFont(Courier_New_15_Font);
    ================================================
    Now it looks not the same but similar to the way I wanted. Thus my question becomes : why it can't work correctly with "Times_New_Roman", but with "Courier_New" in the large program, they both displayed correctly in my small test program ? Is it because it takes too much resource to load the "Times_New_Roman" font ?
    Frank

  • Can not display ImageIcon in a JLabel where you want in the code ???

    Hello, everybody. I need your help to solve a problem I am on it for 2 days now :
    In the constructor of my class, I have a lot of initializing methods. If I try to display an image (with ImageIcon in a JLabel) within one of these methods, there is no problem and the image is correctely displayed. To try that, I use an image stored on my local disk in "c:\\".
    public class Bedes extends javax.swing.JFrame {
    public Bedes() {
    initComponents();
    -- further initializations
    initConnection();
    public void initConnection() {
    try {
    String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
    Properties systemProperties = System.getProperties();
    systemProperties.put("jdbc.drivers", driverName);
    System.setProperties(systemProperties);
    String dbURL = "jdbc:odbc:Bandes Dessin�es";
    String strUtilisateur = "bedes";
    String strMotDePasse = "cdle";
    connectBedes = DriverManager.getConnection(dbURL,strUtilisateur,strMotDePasse);
    catch (Exception e) {
    System.out.println("Exception in DB Contact " + e);
    // Here, I display an image in my JLabel, and it works :
    couvertureAlbumString = "c:\\myImage.jpg";
    couvertureAlbumsIcon = new ImageIcon(couvertureAlbumString);
    couvertureAlbumsJLabel.setIcon(couvertureAlbumsIcon);
    couvertureAlbumsJLabel.repaint();
    }The problem is that I do not want to display these images there, but in a method that read some data's in a Database (with "try"-"catch" blocks). If there is a name of an image store in the DB, then it must be displayed in the JLabel (located in a JFrame -> JDeskTopPane -> JTabbedPane -> JPanel).
    private void searchDetailsForAlbum(String albumsDetailsToSearch) {
    String nomImageCouverture;
    String couvertureAlbumString;
    ImageIcon couvertureAlbumsIcon;
    try {
    PreparedStatement requeteDetailsAlbums = connectBedes.prepareStatement("SELECT * FROM bandes_dess WHERE bede_nom_tome = ?");
    requeteDetailsAlbums.setString(1, albumsDetailsToSearch);
    ResultSet resultatDetailsAlbums = requeteDetailsAlbums.executeQuery();
    resultatDetailsAlbums.next();
    collectionAlbumsJTextField.setText(resultatDetailsAlbums.getString(6));
    genreAlbumsJTextField.setText(resultatDetailsAlbums.getString(9));
    dessinateurAlbumsJTextField.setText(resultatDetailsAlbums.getString(10));
    scenaristeAlbumsJTextField.setText(resultatDetailsAlbums.getString(11));
    coloristeAlbumsJTextField.setText(resultatDetailsAlbums.getString(12));
    prixAchatAlbumsJTextField.setText(resultatDetailsAlbums.getString(13));
    // Here is the name of the Image to de read
    nomImageCouverture = resultatDetailsAlbums.getString(14);
    catch (Exception e) {
    System.out.println("Exception in searchDetailsForAlbum" + e);
    couvertureAlbumString = "c:\\";
    // Here, I check if there is a name for a picture in the DB
    if (!(nomImageCouverture.equals("No"))) {
    // If Yes, I want to display it
    couvertureAlbumString = couvertureAlbumString + nomImageCouverture;
    couvertureAlbumsIcon = new ImageIcon(couvertureAlbumString);
    couvertureAlbumsJLabel.setIcon(couvertureAlbumsIcon);
    couvertureAlbumsJLabel.repaint();
    }My JLabel is well displayed, but empty, without any image on it. WHY ???
    MLK, you asked me to add some debug code. OK, with pleasure, but what is that "debug code" ???
    Thanks a lot in advance if you could help me.
    Christian.

    DEBUG: couvertureAlbumString: c:\Aldebaran-La-Photo
    OK, the extension of the file was NOT present !!!
    I added it and ..... it works pretty good !!!
    Thank you for your idea of the DEBUG.
    Christian.

  • JLabel components not being displayed on the content Panel in Applet

    Hi everyone!!
    Plz give a solution to the following problem:
    I have an applet in which i have JPanel component and on that component i am adding a lot of JLabel components but the problem is that the JLabel components are not displayed on the applet unless i minimize or maximize the applet.
    kindly give solution to the problem.
    Thanks

    Howdy,
    code would be helpful. Here is a very simple JApplet that displays labels okay here in appletviewer. You talk of applets and JLabels. I assume you are using JApplets.
    import javax.swing.*;
    import java.applet.*;
    import java.awt.*;
    public class AppletPie extends JApplet {
         public void init() {
              Container cp = getContentPane();
              cp.setLayout(new FlowLayout());
              cp.add(new JLabel("Show"));
              cp.add(new JLabel("up"));
              cp.add(new JLabel("you"));
              cp.add(new JLabel("dumb"));
              cp.add(new JLabel("labels"));
    }Perhaps something in this code will help you to solve your problem.
    regards
    sjl

  • Set top and bottom inset spacing values in Text Frame Options via jsx script

    I am looking for a way to set the top and bottom inset spacing values only to 2 points in Text Frame Options via a .jsx scrpt.
    For years, I have used a script that sets Preferences, such as:
    with(app.storyPreferences){
        opticalMarginAlignment = false;
        opticalMarginSize = 12;                // pts
    I would like to add the code to this same script that would make Top = 0p2 and Bottom 0p2 but leave Left and Right as 0p0.
    Any help would be greatly appreciated.

    Here is the full .jsx file that we now use to set preferences.
    Ideally, this could be modified to include setting any text frame created to have 0p2 inset Top and Bottom, but 0p0 Left and Right:
    //ApplicationTextDefaults
    //An InDesign CS2 JavaScript
    //Sets the application text defaults, which will become the text defaults for all
    //new documents. Existing documents will remain unchanged.
    with(app.textDefaults){
        alignToBaseline = false;        // align to baseline grid
        try {
    //        appliedFont = app.fonts.item("Times New Roman");
            appliedFont = app.fonts.item("Helvetica");
        catch (e) {}
        try {
            fontStyle = "Medium";
        catch (e) {}
        autoleading = 100;
        balanceRaggedLines = false;
        baselineShift = 0;
        capitalization = Capitalization.normal;
        composer = "Adobe Paragraph Composer";
        desiredGlyphScaling = 100;
        desiredLetterSpacing = 0;
        desiredWordSpacing = 100;
        dropCapCharacters = 0;
        if (dropCapCharacters != 0) {
            dropCapLines = 3;
            //Assumes that the application has a default character style named "myDropCap"
            //dropCapStyle = app.characterStyles.item("myDropCap");
        fillColor = app.colors.item("Black");
        fillTint = 100;
        firstLineIndent = "0pt";
    //    firstLineIndent = "14pt";
        gridAlignFirstLineOnly = false;
        horizontalScale = 100;
        hyphenateAfterFirst = 3;
        hyphenateBeforeLast = 4;
        hyphenateCapitalizedWords = false;
        hyphenateLadderLimit = 1;
        hyphenateWordsLongerThan = 5;
        hyphenation = true;
        hyphenationZone = "3p";
        hyphenWeight = 9;
        justification = Justification.leftAlign;
        keepAllLinesTogether = false;
        keepLinesTogether = true;
        keepFirstLines = 2;
        keepLastLines = 2;
        keepWithNext = 0;
        kerningMethod = "Optical";
        kerningValue = 0;
        leading = 6.3;
    //    leading = 14;
        leftIndent = 0;
        ligatures = true;
        maximumGlyphScaling = 100;
        maximumLetterSpacing = 0;
        maximumWordSpacing = 160;
        minimumGlyphScaling = 100;
        minimumLetterSpacing = 0;
        minimumWordSpacing = 80;
        noBreak = false;
        otfContextualAlternate = true;
        otfDiscretionaryLigature = true;
        otfFigureStyle = OTFFigureStyle.proportionalOldstyle;
        otfFraction = true;
        otfHistorical = true;
        otfOrdinal = false;
        otfSlashedZero = true;
        otfSwash = false;
        otfTitling = false;
        overprintFill = false;
        overprintStroke = false;
        pointSize = 6.3;
    //    pointSize = 11;
        position = Position.normal;
        rightIndent = 0;
        ruleAbove = false;
        if(ruleAbove == true){
            ruleAboveColor = app.colors.item("Black");
            ruleAboveGapColor = app.swatches.item("None");
            ruleAboveGapOverprint = false;
            ruleAboveGapTint = 100;
            ruleAboveLeftIndent = 0;
            ruleAboveLineWeight = .25;
            ruleAboveOffset = 14;
            ruleAboveOverprint = false;
            ruleAboveRightIndent = 0;
            ruleAboveTint = 100;
            ruleAboveType = app.strokeStyles.item("Solid");
            ruleAboveWidth = RuleWidth.columnWidth;
        ruleBelow = false;
        if(ruleBelow == true){
            ruleBelowColor = app.colors.item("Black");
            ruleBelowGapColor = app.swatches.item("None");
            ruleBelowGapOverprint = false;
            ruleBelowGapTint = 100;
            ruleBelowLeftIndent = 0;
            ruleBelowLineWeight = .25;
            ruleBelowOffset = 0;
            ruleBelowOverprint = false;
            ruleBelowRightIndent = 0;
            ruleBelowTint = 100;
            ruleBelowType = app.strokeStyles.item("Solid");
            ruleBelowWidth = RuleWidth.columnWidth;
        singleWordJustification = SingleWordJustification.leftAlign;
        skew = 0;
        spaceAfter = 0;
        spaceBefore = 0;
        startParagraph = StartParagraph.anywhere;
        strikeThru = false;
        if(strikeThru == true){
            strikeThroughColor = app.colors.item("Black");
            strikeThroughGapColor = app.swatches.item("None");
            strikeThroughGapOverprint = false;
            strikeThroughGapTint = 100;
            strikeThroughOffset = 3;
            strikeThroughOverprint = false;
            strikeThroughTint = 100;
            strikeThroughType = app.strokeStyles.item("Solid");
            strikeThroughWeight = .25;
        strokeColor = app.swatches.item("None");
        strokeTint = 100;
        strokeWeight = 0;
        tracking = 0;
        underline = false;
        if(underline == true){
            underlineColor = app.colors.item("Black");
            underlineGapColor = app.swatches.item("None");
            underlineGapOverprint = false;
            underlineGapTint = 100;
            underlineOffset = 3;
            underlineOverprint = false;
            underlineTint = 100;
            underlineType = app.strokeStyles.item("Solid");
            underlineWeight = .25
        verticalScale = 100;
    //Units & Increments preference panel
    //Must do this to make sure our units that we set are in points. The vert and horiz
    //units that get set default to the current measurement unit. We set it to points
    //so we can be sure of the value. We'll reset it later to the desired setting.
    with(app.viewPreferences){
        horizontalMeasurementUnits = MeasurementUnits.points;    // Ruler Units, horizontal
        verticalMeasurementUnits = MeasurementUnits.points;        // Ruler Units, vertical
    //General preference panel
    with(app.generalPreferences){
        pageNumbering = PageNumberingOptions.section;    // Page Numbering, View
        toolTips = ToolTipOptions.normal;                    // Tool Tips
    // Not supported in CS4
    //    toolsPalette = ToolsPaletteOptions.doubleColumn;    // Floating Tool Palette
        completeFontDownloadGlyphLimit = 2000;                // Always Subset Fonts...
        try {
            //Wrapped in try/catch in case it is run with CS4 and earlier to avoid the error
            preventSelectingLockedItems = false;                // Needed for CS5+
        catch (e) {}
    //Type preference panel
    with (app.textEditingPreferences){
        tripleClickSelectsLine = true;    // Triple Click to Select a Line
        smartCutAndPaste = true;        // Adjust Spacing Automatically when Cutting and Pasting Words
        dragAndDropTextInLayout = false;    // Enable in Layout View
        allowDragAndDropTextInStory = true;    // Enable in Story Editor
    with(app.textPreferences){
        typographersQuotes = true;            // Use Typographer's Quotes
        useOpticalSize = true;                // Automatically Use Correct Optical Size
        scalingAdjustsText = true;            // Adjust Text Attributes when Scaling
        useParagraphLeading = false;    // Apply Leading to Entire Paragraphs
        linkTextFilesWhenImporting = false;    // Create Links when Placing Text and Spreadsheet Files
    // Missing following (Font Preview Size, Past All Information/Text Only)
    //Advanced Type preference panel
    with(app.textPreferences){
        superscriptSize = 58.3;                // Superscript, size
        superscriptPosition = 33.3;            // Superscript, position
        subscriptSize = 58.3;                // Subscript, size
        subscriptPosition = 33.3;            // Subscript, position
        smallCap = 70;                        // Smallcap
    with(app.imePreferences){
        inlineInput = false;                // Use Inline Input for Non-Latin Text
    //Composition preference panel
    with(app.textPreferences){
        highlightKeeps = false;                    // Keep Violations
        highlightHjViolations = false;            // H&J Violations
        highlightCustomSpacing = false;            // Custom Tracking/Kerning
        highlightSubstitutedFonts = true;    // Substituted Fonts
        highlightSubstitutedGlyphs = false;    // Substituted Glyphs
        justifyTextWraps = false;                // Justify Text Next to an Object
        abutTextToTextWrap = true;                // Skip by Leading
        zOrderTextWrap = false;                    // Text Wrap Only Affects Text Beneath
    //Units & Increments preference panel
    with(app.viewPreferences){
        rulerOrigin = RulerOrigin.spreadOrigin;                    // Ruler Units, origin
    //    These are set at the end of the script after all the changes have been made
    //    horizontalMeasurementUnits = MeasurementUnits.points;    // Ruler Units, horizontal
    //    verticalMeasurementUnits = MeasurementUnits.inches;        // Ruler Units, vertical
        pointsPerInch = 72;                    // Point/Pica Size, Points/Inch
        cursorKeyIncrement = 1;                // Keyboard Increment, Cursor Key
    with(app.textPreferences){
        baselineShiftKeyIncrement = 2;    // Keyboard Increment, Baseline Shift
        leadingKeyIncrement = 2;        // Keyboard Increment, Size/Leading
        kerningKeyIncrement = 20;            // Keyboard Increment, Kerning
    //Grids preference panel
    with(app.gridPreferences){
        baselineColor = UIColors.lightBlue;    // Baseline Grid, Color
        baselineStart = 48;                        // Baseline Grid, Start
        baselineDivision = 6;                    // Baseline Grid, Increment Every
        baselineViewThreshold = 50;                // Baseline Grid, View Threshold
        baselineGridRelativeOption = BaselineGridRelativeOption.topOfPageOfBaselineGridRelativeOption;    // Baseline Grid, Relative To
        gridColor = UIColors.lightGray;            // Document Grid, Color
        horizontalGridlineDivision = 12;    // Document Grid, Horizontal, Gridline Every
        horizontalGridSubdivision = 12;            // Document Grid, Horizontal, Subdivisions
        verticalGridlineDivision = 12;            // Document Gird, Vertical, Gridline Every
        verticalGridSubdivision = 12;            // Document Grid, Vertical, Subdivisions
        gridsInBack = true;                        // Grids in Back
        documentGridSnapto = false;                // snap to grid or not
        documentGridShown = false;                // show document grid
    //Guides & Pasteboard preference panel
    with(app.documentPreferences){
        marginGuideColor = UIColors.violet;                // Color, Margins
        columnGuideColor = UIColors.magenta;            // Color, Columns
    with(app.pasteboardPreferences){
        bleedGuideColor = UIColors.fiesta;                // Color, Bleed
        slugGuideColor = UIColors.gridBlue;                // Color, Slug
        previewBackgroundColor = UIColors.lightGray;    // Color, Preview Background
        minimumSpaceAboveAndBelow = 72;                    // Minimum Vertical Offset
    with(app.viewPreferences){
        guideSnaptoZone = 4;                            // Snap to Zone
    with(app.guidePreferences){
        guidesInBack = false;                            // Guides in Back
    //Dictionary preference panel
    with(app.dictionaryPreferences){
        composition = ComposeUsing.both;    // Hyphenatin Exceptions, Compose Using
        mergeUserDictionary = false;    // Merge User Dictionary into Document
        recomposeWhenChanged = true;    // Recompose All Stories When Modified
    // Missing (Lang, Hyph, Spelling, Double Quotes, Single Quotes)
    //Spelling preference panel
    with(app.spellPreferences){
        checkMisspelledWords = true;                    // Find, Misspelled Words
        checkRepeatedWords = true;                        // Find, Repeated Words
        checkCapitalizedWords = true;                    // Find, Uncapitalized Words
        checkCapitalizedSentences = true;                // Find, Uncapitalized Sentences
        dynamicSpellCheck = true;                        // Enable Dynamic Spelling
        misspelledWordColor = UIColors.red;                // Color, Misspelled Words
        repeatedWordColor = UIColors.green;                // Color, Repeated Words
        uncapitalizedWordColor = UIColors.green;    // Color, Uncapitalized Words
        uncapitalizedSentenceColor = UIColors.green;    // Color, Uncapitalized Sentences
    //Autocorrect preference panel
    with(app.autoCorrectPreferences){
        autoCorrect = true;                            // Enable Autocorrect
        autoCorrectCapitalizationErrors = false;    // Autocorrect Capitalization
    // Missing (Language, Misspelled word pairs)
    //Display Performance preference panel
    with(app.displayPerformancePreferences){
        defaultDisplaySettings = ViewDisplaySettings.typical;    // Preserve Object-Level
        persistLocalSettings = false;
    // Missing (antialiasiing, greek below
    //Story Editor Display preference panel
    with(app.galleyPreferences){
        textColor = InCopyUIColors.black;                // Text Color
        backgroundColor = InCopyUIColors.white;            // Background
        smoothText = true;                                // Enable Anti-Aliasing
        antiAliasType = AntiAliasType.grayAntialiasing;    // Type
        cursorType = CursorTypes.standardCursor;    // Cursor Type
        blinkCursor = true;                                // Blink
    // Missing (Font, Size, Line Spacing & Theme)
    //File Handling preference panel
    with(app.generalPreferences){
        includePreview = true;                        // Always Save Preview Images with Doc
        previewSize = PreviewSizeOptions.medium;    // Preview Size
    with(app.clipboardPreferences){
        preferPDFWhenPasting = false;                // Prefer PDF When Pasting
        copyPDFToClipboard = true;                    // Copy PDF to Clipboard
        preservePdfClipboardAtQuit = false;            // Preserve PDF Data at Quit
    // Missing (Enable Version Cue)
    //    Optical margin (hanging punctuation, outside margins)
    with(app.storyPreferences){
        opticalMarginAlignment = false;
        opticalMarginSize = 12;                // pts
    //Wrap Up (do at end of script)
    //Units & Increments preference panel
    //Must do this to make sure our units that we set are in points. The vert and horiz
    //units that get set default to the current measurement unit. We set it to points
    //so we can be sure of the value. We'll reset it later to the desired setting.
    with(app.viewPreferences){
        horizontalMeasurementUnits = MeasurementUnits.picas;    // Ruler Units, horizontal
        verticalMeasurementUnits = MeasurementUnits.inches;    // Ruler Units, vertical
    //    These two flags are turned off to avoid the error message about
    //    missing image links when InDesign opens an ad. This can especially
    //    be a problem when doing batch processes.
    with(app.linkingPreferences){
        checkLinksAtOpen = false;            // checkbox: true/false
        findMissingLinksAtOpen = false;        // checkbox: true/false

  • "Line Spacing" vs. leading

    How does "Line Spacing" in static or dynamic text fields
    (explicitliy set in the "Formatting Options" window) compare w/
    "leading" when creating a text field w/ AS?
    Is a "Line Spacing" setting of 10 the same as my_fmt.leading
    = 10;?
    In a Flash 7 file I'm trying to get the spacing between lines
    in an AS-created text field to be closer than default, but it seems
    that leading can be a positive value. But if a similar static field
    looks good w/ Line Spacing set at 0, why is there no equivalent w/
    leading?

    To clarify... If the query row is omitted from the
    indexed/array notation, then isValid() and <cfparam />
    produce different results.
    In the attached code example below, the query row was omitted
    intentionally to illustrate.
    Two possible solutions are:
    1) Make isValid() throw an error (so that they both throw an
    error)
    2) Make <cfparam /> not throw an error (so that they
    both do not throw an error)
    I feel the behavior should be consistent. Does anyone feel
    otherwise? If the behavior should be consistent, then which
    solution, or other solution, is preferred?
    Let's discuss!
    Thanks,
    -Aaron
    ---------

  • Permanently save line spacing in a multi-line text field

    Me: Adobe Acrobat 8 Pro, Windows Vista
    (I think the people who will be using the form have Reader 7 on Windows)
    I work in a doctors' clinic, and we use phone message sheets to document conversations between the patients/us/nurses/doctors, and I scanned the form and made it into a fillable PDF for our secretaries to fill out more quickly. The "message" area has pre-printed lines on it, and the multi-line text field I placed there needs to match up to the lines. I used the Rich Text Formatting options to set it to "Exactly 24 Points," but I can't get it to KEEP the formatting permanently. The only way I could get it to save the formatting in that field was to put a space in it and then save it, and then give that to the 2 phone secretaries. It works perfectly the first time, but instead of just closing/re-opening the file to start a new message, one of the secretaries highlights everything in the "message" field and deletes it... which deletes the line spacing formatting. I've told her
    b numerous
    times to leave that starting space in the field, but she "forgets" so all of her messages look messed up. So is there a way to force that line spacing
    b PERMANENTLY
    ???? Here's a shrunken screenshot of the field -- I wish I could just erase the lines altogether so the spacing wouldn't matter, but the secretaries type/print the message out, then the nurses/docs write on the page with pen so the lines have to stay. http://img187.imageshack.us/my.php?image=notepreviewph8.jpg
    Thanks!

    You can set the font size of the text. Then play with the underlines in the original document to match the needs of the font that is used. Print to a new PDF and then use replace pages to put the new page into the form without changing the form fields. I was able to do this with a word processing document by adding underlining in the document with 12 pt and setting the font to 12 pt in the text field. You can play with the font, the border of the field, and the underlining in the original document to get the desired result. Is this optimal, probably not. However it does the job.

  • Indesign CS3 : Inset spacing preview in text box not there anymore.

    Hi!
    In Indesign CS2, I could see a "preview" of the inset spacing of my text boxes in "Preview Mode (W)".
    In Indesign CS3, I can't see it anymore unless I move my text boxes (the preview of the inset spacing of my text boxes shows only when I move the boxes).
    This is bad, because I can't see really fast which boxes have inset spacing and which ones don't.
    Please help me!
    Thanks,
    Chris.

    Yes.
    Normal Mode hides all of those things. But Preview Mode shows all of those things (unless otherwise selected in the "View" menu).
    I need to see the inset spacing of my text boxes in Preview Mode without having to move them.
    Here is an image of my text box in Preview Mode (guides, invisible characters, etc. are visible, but not the inset spacing): http://www.chris.lafacade.com/share/01.jpg
    Here is an image of my text box in Preview Mode while I move my box. As you can see, the inset spacing shows: http://www.chris.lafacade.com/share/02.jpg
    I need the inset spacing to show all the time in Preview Mode.
    Thanks!
    Chris.

Maybe you are looking for

  • Currency translation differences with an effect on earnings

    Product Version: SAP R/3 46.C Componente: EC-CS-CSF-E Currency Translation In currency translation program of ECCS (tx CX40) the prior year portion of translation differences that affects earnings is posted in current period in the earnings retain it

  • DAQmx driver for DAQ 6009? Need DAQ Assistant in Block Panel palette.

    Do I understand things right?  The Ni USB DAQ 6009 is supported in DAQmx base and not DAQmx, or is this only true for the 6008? I need the DAQ Assistant in my LV 2009 Block Panel palette.  Do I go to my Ni-DAQmx 8.8 CDs, or do I download something.  

  • Creating new Enterprise wiki site collection or creating a new subsite, or creating a new library

    I have SharePoint 2013 web application, which has enterprise wiki site collection for our finance department. Now I need to create a new site for our HR department. The two sites will differ in the following:- Each department have different permissio

  • Anyone else struggling with iPhone 5 battery ?

    iPhone 5 bought direct from Apple on release, set up as a new phone out the box, I have pretty much everything turned off, and the battery life is still struggling to get me through the day, and that is without what I would consider excessive use. No

  • Transferring from old iPod to new iPod

    I have an iPod mini, but have just got a new iPod. Some of the songs on my mini are from my old computer, so I no longer have them. Is it possible to transfer songs directly from iPod to iPod if they are no longer in iTunes?