JTextArea in JScrollPane - jscrollpane

I want to make JTextArea scrollable...
I have tried following code.. but am not getting why its not working... Pls help !
jacontactsDeatil = new JTextArea();
jspn = new JScrollPane();
jspn.setLayout(null);
jspn.setBounds(10, 170, 950, 300);
jspn.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
jspn.isWheelScrollingEnabled();
jspn.setVisible(true);
jspn.setAutoscrolls(true);
jspn.setEnabled(true);
jspn.setBackground(Color.orange);
jspn.add(jacontactsDetail);
jspn.repaint();
jacontactsDetail.setBounds(0,0,jspn.getWidth(),jspn.getHeight());

One option is to use the JTextArea and the JScrollPane together with a GroupLayout.
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup().
addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 328,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup().
addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 79,
javax.swing.GroupLayout.PREFERRED_SIZE)
);

Related

How to get beacons UUID, when scanning for BLE

I am using this library https://pub.dev/packages/flutter_reactive_ble for scanning the beacon. and for broadcasting a beacon I am using an android app called beacon simulator and it has got beacon UUID, majorID and minorID for each hosted beacon.
here the UUID is '0546b93b-f113-438d-8bab-b9e766dd'
but while scanning I am unable to look out for UUID instead I am getting this response in this structure.
DiscoveredDevice(id: 14:49:2F:BB:D5:97, name: , serviceData: {}, serviceUuids: [], manufacturerData: [76, 0, 2, 21, 5, 70, 185, 59, 241, 19, 67, 141, 139, 171, 185, 231, 102, 208, 17, 119, 0, 0, 0, 0, 191], rssi: -39)
Is there any way I can get the beacon's UUID in the format '0546b93b-f113-438d-8ba...'
Or any better way to uniquely identify a device? I know we can search for the device's Bluetooth address, but that just keeps on changing.
Thanks in advance.

How can I split an array into specified lines when printing?

New to software development, I'm working through Big Nerd Ranch's book 'Swift Programming'. One of the challenges set by the book is to print an array within a dictionary that contains 15 zip codes and to have them split across three lines in groups of five. The formatting must exactly match how it appears in the book.
I have tried to solve the issue using the information taught in the book with assistance from the developer documentation.
No dice.
This is what I need to print:
Caterham has the following zip codes: [111, 111, 111, 111, 111,
222, 222, 222, 222, 222,
333, 333, 333, 333, 333]
However this is the closest I can get...
var areaCodes = ["Caterham": [111, 111, 111, 111, 111], "Coulsdon": [222, 222, 222, 222, 222], "Purley": [333, 333, 333, 333, 333]]
var caterhamCodes : [Int] = []
for (_, values) in areaCodes {
caterhamCodes += values
}
print("Caterham has the following codes: \(caterhamCodes[0...4]),")
print(" \(caterhamCodes[5...9]),")
print(" \(caterhamCodes[10...14]).")
which prints:
Caterham has the following postcodes: [111, 111, 111, 111, 111],
[222, 222, 222, 222, 222],
[333, 333, 333, 333, 333].
Essentially, I need what I have above minus some square brackets and without the punctuation after each time a block of zip codes is printed. The book specifies that I might need to use a parameter called terminator. It also mentions I might need to learn how to represent special characters in string literals.
I appreciate that this is probably a high level question with a simple answer, but I'm only a few weeks into learning, so I hope I can be forgiven for asking at least a few silly questions!
Welcome to the developer community and have a nice stay!
I am trying to put answer as simple as possible, so here is my attempt:
var areaCodes = ["Caterham": [111, 111, 111, 111, 111],
"Coulsdon": [222, 222, 222, 222, 222],
"Purley": [333, 333, 333, 333, 333]]
let codesArray = areaCodes.values.sorted(by: { $0[0] < $1[0] })
let caterhamString = "Caterham has the following zip codes: ["
var printString = caterhamString
for (index, area) in codesArray.enumerated() {
for code in area {
printString += "\(code), "
}
if index != codesArray.count - 1 {
printString += "\n" + String(repeating: " ", count: caterhamString.count)
}
}
print(printString.dropLast(2).appending("]"))
Hope this helps! Good luck!
Here is a way of getting the desired output :
let intro = "Caterham has the following zip codes: ["
let spaces = ",\n" + String(repeating: " ", count: intro.count)
let areaCodes = ["Caterham": [111, 111, 111, 111, 111], "Coulsdon": [222, 222, 222, 222, 222], "Purley": [333, 333, 333, 333, 333]]
let codes = areaCodes.values.sorted { $0[0] < $1[0] }
var output = intro +
codes.map { $0.map{ String($0) }.joined(separator: ", ") }
.joined(separator: spaces)
+ "]"
print(output)
Which prints
Caterham has the following zip codes: [111, 111, 111, 111, 111,
222, 222, 222, 222, 222,
333, 333, 333, 333, 333]

scrapy sending mail got an ERROR: Unable to send mail. object of type 'module' has no len()

I wanna send email when spider closed, code is like this:
def close(spider, reason):
# mailer = MailSender.from_settings(self.settings)
from scrapy.mail import MailSender
mailer = MailSender(
smtphost="smtp.163.com",
mailfrom="rhys***#163.com",
smtpuser="rhys***g#163.com",
smtppass="***",
smtpport=25
)
body = u"""
content
"""
subject = u'title'
mailer.send(to=["rhys***#qq.com"],
subject=subject.encode("utf-8"),
body=body.encode("utf-8"),
cc=['12202012**#qq.com'])
But I got an error like this:
[twisted] CRITICAL: Unhandled Error
Traceback (most recent call last):
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/python/log.py", line 103, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/python/log.py", line 86, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/python/context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/python/context.py", line 85, in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/internet/posixbase.py", line 597, in _doReadOrWrite
why = selectable.doRead()
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/internet/tcp.py", line 208, in doRead
return self._dataReceived(data)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/internet/tcp.py", line 214, in _dataReceived
packages/twisted/internet/tcp.py", line 214, in _dataReceived
rval = self.protocol.dataReceived(data)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/protocols/tls.py", line 330, in dataReceived
self._flushReceiveBIO()
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/protocols/tls.py", line 295, in _flushReceiveBIO
ProtocolWrapper.dataReceived(self, bytes)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/protocols/policies.py", line 120, in dataReceived
self.wrappedProtocol.dataReceived(data)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/protocols/basic.py", line 571, in dataReceived
why = self.lineReceived(line)
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/mail/smtp.py", line 995, in lineReceived
why = self._okresponse(self.code, b'\n'.join(self.resp))
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/mail/smtp.py", line 1044, in smtpState_to
return self.smtpState_toOrData(0, b'')
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/mail/smtp.py", line 1062, in smtpState_toOrData
self.sendLine(b'RCPT TO:' + quoteaddr(self.lastAddress))
File "/home/rhys/.pyenv/versions/2.7.5/envs/p2spider/lib/python2.7/site-
packages/twisted/mail/smtp.py", line 179, in quoteaddr
res = email.utils.parseaddr(addr)
File "/home/rhys/.pyenv/versions/2.7.5/lib/python2.7/email/utils.py", li
ne 215, in parseaddr
addrs = _AddressList(addr).addresslist
File "/home/rhys/.pyenv/versions/2.7.5/lib/python2.7/email/_parseaddr.py
", line 457, in __init__
self.addresslist = self.getaddrlist()
File "/home/rhys/.pyenv/versions/2.7.5/lib/python2.7/email/_parseaddr.py
", line 217, in getaddrlist
while self.pos < len(self.field):
exceptions.TypeError: object of type 'module' has no len()
anybody can explain why?
I use python2.7 and scapy1.4. if I comment the code mentioned above everything is just ok
thanks
I bumped to twisted 17.9 and the problem went away.

Typoscript: If page is not equal to

I'm trying to include a typoscript on the child pages of the page it's included on.
On page id 272 I have included in the setup a typoscript file:
<INCLUDE_TYPOSCRIPT: source="FILE:fileadmin/templates/typoscript/fancyBoxPopup.ts">
And I only want this typoscript to run on that pages children.
So I tried this:
[globalVar = TSFE:id != 252, 253, 254, 270, 272, 271, 273, 274]
But that makes the script run on all children and parents (those listed in the statement)
Here is the full script:
[globalVar = TSFE:id != 252, 253, 254, 270, 272, 271, 273, 274]
page.includeJS >
page.includeJS.ieFixes = fileadmin/templates/js/ieFixes.js
columnWidth {
page {
main = 400
}
}
[end]
I think I manage to fix it.
I found PIDupinRootline.
So the final code looks like this:
[PIDupinRootline = 252,253,254,270,272,271,273,274]
...
[end]

Error in XML Error Domain=NSXMLParserErrorDomain Code=39?

I have following xml
<?xml version='1.0' encoding='UTF-8'?>
<businesses>
<business>
<businessCount>1</businessCount>
<dealsCount>3</dealsCount>
<city>asdf</city>
<state>asdf</state>
<country>akdsjfasdf</country>
<latitude></latitude>
<longitude></longitude>
</business>
<business>
<businessCount>1</businessCount>
<dealsCount>1</dealsCount>
<city>karachi</city>
<state>sindg</state>
<country>Pakistan</country>
<latitude>24.8567436</latitude>
<longitude>66.8734836</longitude>
</business>
<business>
<businessCount>1</businessCount>
<dealsCount>2</dealsCount>
<city>karachi</city>
<state>sindh</state>
<country>pakistan</country>
<latitude>24.893379</latitude>
<longitude>67.028061</longitude>
</business>
</businesses>
but getting the following error while parsing
Error Domain=NSXMLParserErrorDomain Code=39 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 39.)"
I read the documentation and also varify the syntax of XML, but didn't find what issue is with it.
Can anyone give any idea or help?
check these error code in apple documentation
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html
enum {
NSXMLParserInternalError = 1,
NSXMLParserOutOfMemoryError = 2,
NSXMLParserDocumentStartError = 3,
NSXMLParserEmptyDocumentError = 4,
NSXMLParserPrematureDocumentEndError = 5,
NSXMLParserInvalidHexCharacterRefError = 6,
NSXMLParserInvalidDecimalCharacterRefError = 7,
NSXMLParserInvalidCharacterRefError = 8,
NSXMLParserInvalidCharacterError = 9,
NSXMLParserCharacterRefAtEOFError = 10,
NSXMLParserCharacterRefInPrologError = 11,
NSXMLParserCharacterRefInEpilogError = 12,
NSXMLParserCharacterRefInDTDError = 13,
NSXMLParserEntityRefAtEOFError = 14,
NSXMLParserEntityRefInPrologError = 15,
NSXMLParserEntityRefInEpilogError = 16,
NSXMLParserEntityRefInDTDError = 17,
NSXMLParserParsedEntityRefAtEOFError = 18,
NSXMLParserParsedEntityRefInPrologError = 19,
NSXMLParserParsedEntityRefInEpilogError = 20,
NSXMLParserParsedEntityRefInInternalSubsetError = 21,
NSXMLParserEntityReferenceWithoutNameError = 22,
NSXMLParserEntityReferenceMissingSemiError = 23,
NSXMLParserParsedEntityRefNoNameError = 24,
NSXMLParserParsedEntityRefMissingSemiError = 25,
NSXMLParserUndeclaredEntityError = 26,
NSXMLParserUnparsedEntityError = 28,
NSXMLParserEntityIsExternalError = 29,
NSXMLParserEntityIsParameterError = 30,
NSXMLParserUnknownEncodingError = 31,
NSXMLParserEncodingNotSupportedError = 32,
NSXMLParserStringNotStartedError = 33,
NSXMLParserStringNotClosedError = 34,
NSXMLParserNamespaceDeclarationError = 35,
NSXMLParserEntityNotStartedError = 36,
NSXMLParserEntityNotFinishedError = 37,
NSXMLParserLessThanSymbolInAttributeError = 38,
NSXMLParserAttributeNotStartedError = 39,
NSXMLParserAttributeNotFinishedError = 40,
NSXMLParserAttributeHasNoValueError = 41,
NSXMLParserAttributeRedefinedError = 42,
NSXMLParserLiteralNotStartedError = 43,
NSXMLParserLiteralNotFinishedError = 44,
NSXMLParserCommentNotFinishedError = 45,
NSXMLParserProcessingInstructionNotStartedError = 46,
NSXMLParserProcessingInstructionNotFinishedError = 47,
NSXMLParserNotationNotStartedError = 48,
NSXMLParserNotationNotFinishedError = 49,
NSXMLParserAttributeListNotStartedError = 50,
NSXMLParserAttributeListNotFinishedError = 51,
NSXMLParserMixedContentDeclNotStartedError = 52,
NSXMLParserMixedContentDeclNotFinishedError = 53,
NSXMLParserElementContentDeclNotStartedError = 54,
NSXMLParserElementContentDeclNotFinishedError = 55,
NSXMLParserXMLDeclNotStartedError = 56,
NSXMLParserXMLDeclNotFinishedError = 57,
NSXMLParserConditionalSectionNotStartedError = 58,
NSXMLParserConditionalSectionNotFinishedError = 59,
NSXMLParserExternalSubsetNotFinishedError = 60,
NSXMLParserDOCTYPEDeclNotFinishedError = 61,
NSXMLParserMisplacedCDATAEndStringError = 62,
NSXMLParserCDATANotFinishedError = 63,
NSXMLParserMisplacedXMLDeclarationError = 64,
NSXMLParserSpaceRequiredError = 65,
NSXMLParserSeparatorRequiredError = 66,
NSXMLParserNMTOKENRequiredError = 67,
NSXMLParserNAMERequiredError = 68,
NSXMLParserPCDATARequiredError = 69,
NSXMLParserURIRequiredError = 70,
NSXMLParserPublicIdentifierRequiredError = 71,
NSXMLParserLTRequiredError = 72,
NSXMLParserGTRequiredError = 73,
NSXMLParserLTSlashRequiredError = 74,
NSXMLParserEqualExpectedError = 75,
NSXMLParserTagNameMismatchError = 76,
NSXMLParserUnfinishedTagError = 77,
NSXMLParserStandaloneValueError = 78,
NSXMLParserInvalidEncodingNameError = 79,
NSXMLParserCommentContainsDoubleHyphenError = 80,
NSXMLParserInvalidEncodingError = 81,
NSXMLParserExternalStandaloneEntityError = 82,
NSXMLParserInvalidConditionalSectionError = 83,
NSXMLParserEntityValueRequiredError = 84,
NSXMLParserNotWellBalancedError = 85,
NSXMLParserExtraContentError = 86,
NSXMLParserInvalidCharacterInEntityError = 87,
NSXMLParserParsedEntityRefInInternalError = 88,
NSXMLParserEntityRefLoopError = 89,
NSXMLParserEntityBoundaryError = 90,
NSXMLParserInvalidURIError = 91,
NSXMLParserURIFragmentError = 92,
NSXMLParserNoDTDError = 94,
NSXMLParserDelegateAbortedParseError = 512
};
typedef NSInteger NSXMLParserError;```