Man arrested at courthouse with gun