+ 20

How to know the number of characters we can place in a line ?

Suppose u make some pattern & it looks fine in your device (because width of pattern is less than width of device) But in other device, it might not get fitted (because it have little less characters capacity per line) So if there will be someway to identify the no. of characters we can put in a line for different devices, then it will easy to give instruction for maintaining pattern. //ie, we can find maximum width we can have for pattern for a device. Some function available for that ?

11th Jan 2019, 12:33 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
16 Answers
+ 12
You maybe finding the solution for java. I have a trick for it - not implemented though. Get the device width java.awt.toolkit.getDefaultToolkit().getScreenSize().getWidth() Measure the approximate length for a character - you may use a ruler 📏😁 Divide the width by approx. length of char and maximum length of a char sequence can be obtained. But this cannot be done practically in SL as it doesn't support java.awt, as we all know
11th Jan 2019, 12:43 PM
Seniru
Seniru - avatar
+ 11
⏩ Prometheus ⏪ We can do error & trial for a particular device , but cannot do for all device. //the idea of this I get from Ace sir answer here (see 1st point) https://www.sololearn.com/Discuss/1652441/?ref=app
11th Jan 2019, 12:36 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 7
As far as I know, I don't think anything except for web supports that. And it seems the only method now is trial and error, unless you know both the screen size and the size of characters
11th Jan 2019, 12:34 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 7
You can get the width of console window with Python and adjust your code for it. Don't be too optimistic thinking you could do this HERE as well: You'll get the values from the compiler PC. ;-)
11th Jan 2019, 1:00 PM
HonFu
HonFu - avatar
+ 7
Hy mohammad elahi welcome to Sololearn q/a Please stop spamming with unrelated answers in q/a section //U can delete your unrealted answers from q/a posts.
11th Jan 2019, 5:38 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 7
Ace sir, if possible in java or kotlin //on SL, even if not possible on SL, then also I would like to know.
12th Jan 2019, 3:50 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 4
11th Jan 2019, 3:37 PM
HonFu
HonFu - avatar
+ 4
Seniru Pasan is there a way of doing it with JavaFX?
12th Jan 2019, 3:36 PM
Shuaib Nuruddin
Shuaib Nuruddin - avatar
+ 4
Seniru Pasan JavaFX is a different GUI toolkit.
13th Jan 2019, 9:34 AM
Shuaib Nuruddin
Shuaib Nuruddin - avatar
12th Jan 2019, 4:07 PM
Seniru
Seniru - avatar
+ 3
13th Jan 2019, 9:34 AM
Seniru
Seniru - avatar
+ 3
Seniru Pasan yes so I suppose I could use your way. Thanks
13th Jan 2019, 9:36 AM
Shuaib Nuruddin
Shuaib Nuruddin - avatar
+ 2
HonFu Not PC though😀 Gaurav Agrawal Once I had read some article exactly how to do this in various language. Now problem is neither I know Java was amongst them or not nor I remember where is the article.
11th Jan 2019, 3:11 PM
Emoji FanBoy
Emoji FanBoy - avatar